Signed-off-by: Rafael Fonseca <r4f4rfs@xxxxxxxxx> --- src/qemu/qemu_conf.c | 4 ++-- src/qemu/qemu_conf.h | 2 +- src/qemu/qemu_driver.c | 9 ++------- tests/testutilsqemu.c | 5 ++--- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c59824006c..f4460e77ec 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -86,12 +86,12 @@ VIR_ONCE_GLOBAL_INIT(virQEMUConfig); static void qemuDriverLock(virQEMUDriverPtr driver) { - virMutexLock(&driver->lock); + g_mutex_lock(&driver->lock); } static void qemuDriverUnlock(virQEMUDriverPtr driver) { - virMutexUnlock(&driver->lock); + g_mutex_unlock(&driver->lock); } #ifndef DEFAULT_LOADER_NVRAM diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index b9ef4551a3..f28486d62b 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -225,7 +225,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(virQEMUDriverConfig, virObjectUnref); /* Main driver state */ struct _virQEMUDriver { - virMutex lock; + GMutex lock; /* Require lock to get reference on 'config', * then lockless thereafter */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d6ed6d3b3f..f6a9edf93c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -645,12 +645,7 @@ qemuStateInitialize(bool privileged, qemu_driver->lockFD = -1; - if (virMutexInit(&qemu_driver->lock) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot initialize mutex")); - VIR_FREE(qemu_driver); - return VIR_DRV_STATE_INIT_ERROR; - } + g_mutex_init(&qemu_driver->lock); qemu_driver->inhibitCallback = callback; qemu_driver->inhibitOpaque = opaque; @@ -1134,7 +1129,7 @@ qemuStateCleanup(void) virPidFileRelease(qemu_driver->config->stateDir, "driver", qemu_driver->lockFD); virObjectUnref(qemu_driver->config); - virMutexDestroy(&qemu_driver->lock); + g_mutex_clear(&qemu_driver->lock); VIR_FREE(qemu_driver); return 0; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index cb68ac0488..27053603a0 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -307,7 +307,7 @@ qemuTestParseCapabilitiesArch(virArch arch, void qemuTestDriverFree(virQEMUDriver *driver) { - virMutexDestroy(&driver->lock); + g_mutex_clear(&driver->lock); if (driver->config) { virFileDeleteTree(driver->config->stateDir); virFileDeleteTree(driver->config->configDir); @@ -386,8 +386,7 @@ int qemuTestDriverInit(virQEMUDriver *driver) !(cpuPower9 = virCPUDefCopy(&cpuPower9Data))) return -1; - if (virMutexInit(&driver->lock) < 0) - return -1; + g_mutex_init(&driver->lock); driver->hostarch = virArchFromHost(); driver->config = virQEMUDriverConfigNew(false, NULL); -- 2.25.2