>From 165abdd77c7db83ebf98232b80d6b988471185c0 Mon Sep 17 00:00:00 2001 From: Bihong Yu <yubihong@xxxxxxxxxx> Date: Tue, 14 Jul 2020 15:44:05 +0800 Subject: [PATCH] qemu: pre-create the dbus directory in qemuStateInitialize 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@xxxxxxxxxx> --- 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 51f6c94..8104287 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 474eb10..3c2145a 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 8e81c30..53980d4 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 e8b15ee..1006f41 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; -- 1.8.3.1