[PATCH 09/43] libxl: convert virMutex to GMutex in libxlPrivate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Rafael Fonseca <r4f4rfs@xxxxxxxxx>
---
 src/libxl/libxl_conf.h   | 6 +++---
 src/libxl/libxl_driver.c | 9 ++-------
 tests/testutilsxen.c     | 9 ++-------
 3 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 07b3373170..b29752ad0c 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -106,7 +106,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(libxlDriverConfig, virObjectUnref);
 
 
 struct _libxlDriverPrivate {
-    virMutex lock;
+    GMutex lock;
 
     virHostdevManagerPtr hostdevMgr;
     /* Require lock to get reference on 'config',
@@ -225,11 +225,11 @@ libxlBuildDomainConfig(virPortAllocatorRangePtr graphicsports,
 static inline void
 libxlDriverLock(libxlDriverPrivatePtr driver)
 {
-    virMutexLock(&driver->lock);
+    g_mutex_lock(&driver->lock);
 }
 
 static inline void
 libxlDriverUnlock(libxlDriverPrivatePtr driver)
 {
-    virMutexUnlock(&driver->lock);
+    g_mutex_unlock(&driver->lock);
 }
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 980984b199..dae20cf453 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -520,7 +520,7 @@ libxlStateCleanup(void)
         virPidFileRelease(libxl_driver->config->stateDir, "driver", libxl_driver->lockFD);
 
     virObjectUnref(libxl_driver->config);
-    virMutexDestroy(&libxl_driver->lock);
+    g_mutex_clear(&libxl_driver->lock);
     VIR_FREE(libxl_driver);
 
     return 0;
@@ -669,12 +669,7 @@ libxlStateInitialize(bool privileged,
         return VIR_DRV_STATE_INIT_ERROR;
 
     libxl_driver->lockFD = -1;
-    if (virMutexInit(&libxl_driver->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("cannot initialize mutex"));
-        VIR_FREE(libxl_driver);
-        return VIR_DRV_STATE_INIT_ERROR;
-    }
+    g_mutex_init(&libxl_driver->lock);
 
     libxl_driver->inhibitCallback = callback;
     libxl_driver->inhibitOpaque = opaque;
diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c
index d50c3003da..fcc7009f74 100644
--- a/tests/testutilsxen.c
+++ b/tests/testutilsxen.c
@@ -87,12 +87,7 @@ libxlDriverPrivatePtr testXLInitDriver(void)
 {
     libxlDriverPrivatePtr driver = g_new0(libxlDriverPrivate, 1);
 
-    if (virMutexInit(&driver->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", "cannot initialize mutex");
-        g_free(driver);
-        return NULL;
-    }
+    g_mutex_init(&driver->lock);
 
     if (!(driver->config = libxlDriverConfigNew()))
         return NULL;
@@ -114,6 +109,6 @@ void testXLFreeDriver(libxlDriverPrivatePtr driver)
 {
     virObjectUnref(driver->config);
     virObjectUnref(driver->xmlopt);
-    virMutexDestroy(&driver->lock);
+    g_mutex_clear(&driver->lock);
     g_free(driver);
 }
-- 
2.25.2






[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux