1 Star 0 Fork 70

mds.lanruo/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
libvirt-leaseshelper-Wait-to-acquire-PID-file.patch 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
Hao_Wang 提交于 2020-09-22 17:11 . backport upstream patches
From 173b80e8f8103f26438d344e9b97335d4e5036b4 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <[email protected]>
Date: Thu, 11 Jun 2020 16:43:22 +0200
Subject: [PATCH 2/6] leaseshelper: Wait to acquire PID file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On a DHCP transaction, dnsmasq runs our leases helper which
updates corresponding JSON files. While one dnsmasq won't run the
leaseshelper in parallel, two dnsmasqs (from two distinct
networks) might. To avoid corrupting JSON file, the leaseshelper
acquires PID file first. Well, the way it's acquiring it is not
ideal - it calls virPidFileAcquirePath(wait = false); which
means, that either it acquires the PID file instantly or returns
an error and does not touch the JSON at all. This in turn means
that there might be a leases record missing. With wait = true,
this won't happen.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1840307
cherry pick from: 876211ef4a192df1603b45715044ec14567d7e9f
Signed-off-by: Michal Privoznik <[email protected]>
Reviewed-by: Daniel P. Berrangé <[email protected]>
---
src/network/leaseshelper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index a1780ca..86c847d 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -160,7 +160,7 @@ main(int argc, char **argv)
pid_file = g_strdup(RUNSTATEDIR "/leaseshelper.pid");
/* Try to claim the pidfile, exiting if we can't */
- if ((pid_file_fd = virPidFileAcquirePath(pid_file, false, getpid())) < 0)
+ if ((pid_file_fd = virPidFileAcquirePath(pid_file, true, getpid())) < 0)
goto cleanup;
/* Since interfaces can be hot plugged, we need to make sure that the
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdslanruo/libvirt.git
[email protected]:mdslanruo/libvirt.git
mdslanruo
libvirt
libvirt
master

搜索帮助