1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-26 14:03:49 +03:00

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@huawei.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Bihong Yu 2020-07-14 15:44:05 +08:00 committed by Ján Tomko
parent 6f59749e4e
commit 3ee423c363
4 changed files with 7 additions and 15 deletions

View File

@ -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)

View File

@ -21,8 +21,6 @@
#include "qemu_conf.h"
#include "qemu_domain.h"
int qemuDBusPrepareHost(virQEMUDriverPtr driver);
char *qemuDBusGetAddress(virQEMUDriverPtr driver,
virDomainObjPtr vm);

View File

@ -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;

View File

@ -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;