1 Star 0 Fork 71

KuhnChen/src-libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
libvirt-qemu-pre-create-the-dbus-directory-in-qemuStateIniti.patch 2.96 KB
一键复制 编辑 原始数据 按行查看 历史
From 3ee423c363b69588e82e522ad1634193284c09a7 Mon Sep 17 00:00:00 2001
From: Bihong Yu <yubihong@huawei.com>
Date: Tue, 14 Jul 2020 15:44:05 +0800
Subject: [PATCH] qemu: pre-create the dbus directory in qemuStateInitialize
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
There are races condiction to make '/run/libvirt/qemu/dbus' directory in
virDirCreateNoFork() while concurrent start VMs, and get "failed to create
directory '/run/libvirt/qemu/dbus': File exists" error message. pre-create the
dbus directory in qemuStateInitialize.
Signed-off-by: Bihong Yu <yubihong@huawei.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_dbus.c | 10 ----------
src/qemu/qemu_dbus.h | 2 --
src/qemu/qemu_driver.c | 7 +++++++
src/qemu/qemu_process.c | 3 ---
4 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c
index 51f6c94e3e..81042876fe 100644
--- a/src/qemu/qemu_dbus.c
+++ b/src/qemu/qemu_dbus.c
@@ -33,16 +33,6 @@
VIR_LOG_INIT("qemu.dbus");
-int
-qemuDBusPrepareHost(virQEMUDriverPtr driver)
-{
- g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
-
- return virDirCreate(cfg->dbusStateDir, 0770, cfg->user, cfg->group,
- VIR_DIR_CREATE_ALLOW_EXIST);
-}
-
-
static char *
qemuDBusCreatePidFilename(virQEMUDriverConfigPtr cfg,
const char *shortName)
diff --git a/src/qemu/qemu_dbus.h b/src/qemu/qemu_dbus.h
index 474eb1058b..3c2145a223 100644
--- a/src/qemu/qemu_dbus.h
+++ b/src/qemu/qemu_dbus.h
@@ -21,8 +21,6 @@
#include "qemu_conf.h"
#include "qemu_domain.h"
-int qemuDBusPrepareHost(virQEMUDriverPtr driver);
-
char *qemuDBusGetAddress(virQEMUDriverPtr driver,
virDomainObjPtr vm);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8e81c30a93..53980d4d78 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -743,6 +743,13 @@ qemuStateInitialize(bool privileged,
goto error;
}
+ if (virDirCreate(cfg->dbusStateDir, 0770, cfg->user, cfg->group,
+ VIR_DIR_CREATE_ALLOW_EXIST) < 0) {
+ virReportSystemError(errno, _("Failed to create dbus state dir %s"),
+ cfg->dbusStateDir);
+ goto error;
+ }
+
if ((qemu_driver->lockFD =
virPidFileAcquire(cfg->stateDir, "driver", false, getpid())) < 0)
goto error;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index e8b15ee3ca..1006f41614 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6466,9 +6466,6 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
- if (qemuDBusPrepareHost(driver) < 0)
- return -1;
-
if (qemuPrepareNVRAM(cfg, vm) < 0)
return -1;
--
2.25.0.windows.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kuhnchen18/src-libvirt.git
git@gitee.com:kuhnchen18/src-libvirt.git
kuhnchen18
src-libvirt
src-libvirt
master

搜索帮助