[libvirt PATCH 10/11] storage: Move and split up storateStateCleanup

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

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/storage/storage_driver.c | 71 +++++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 34 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 05675a5539..3bd5d07efb 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -59,8 +59,6 @@ static virStorageDriverState *driver;
 
 static virMutex mutex = VIR_MUTEX_INITIALIZER;
 
-static int storageStateCleanup(void);
-
 typedef struct _virStorageVolStreamInfo virStorageVolStreamInfo;
 struct _virStorageVolStreamInfo {
     char *pool_name;
@@ -248,6 +246,43 @@ storageDriverAutostart(void)
                                  NULL);
 }
 
+static int
+storageStateCleanupLocked(void)
+{
+    if (!driver)
+        return -1;
+
+    virObjectUnref(driver->caps);
+    virObjectUnref(driver->storageEventState);
+
+    /* free inactive pools */
+    virObjectUnref(driver->pools);
+
+    if (driver->lockFD != -1)
+        virPidFileRelease(driver->stateDir, "driver",
+                          driver->lockFD);
+
+    VIR_FREE(driver->configDir);
+    VIR_FREE(driver->autostartDir);
+    VIR_FREE(driver->stateDir);
+    VIR_FREE(driver);
+
+    return 0;
+}
+
+/**
+ * storageStateCleanup
+ *
+ * Shutdown the storage driver, it will stop all active storage pools
+ */
+static int
+storageStateCleanup(void)
+{
+    VIR_LOCK_GUARD lock = virLockGuardLock(&mutex);
+
+    return storageStateCleanupLocked();
+}
+
 /**
  * virStorageStartup:
  *
@@ -363,38 +398,6 @@ storageStateReload(void)
 }
 
 
-/**
- * storageStateCleanup
- *
- * Shutdown the storage driver, it will stop all active storage pools
- */
-static int
-storageStateCleanup(void)
-{
-    if (!driver)
-        return -1;
-
-    storageDriverLock();
-
-    virObjectUnref(driver->caps);
-    virObjectUnref(driver->storageEventState);
-
-    /* free inactive pools */
-    virObjectUnref(driver->pools);
-
-    if (driver->lockFD != -1)
-        virPidFileRelease(driver->stateDir, "driver",
-                          driver->lockFD);
-
-    VIR_FREE(driver->configDir);
-    VIR_FREE(driver->autostartDir);
-    VIR_FREE(driver->stateDir);
-    storageDriverUnlock();
-    VIR_FREE(driver);
-
-    return 0;
-}
-
 static virDrvOpenStatus
 storageConnectOpen(virConnectPtr conn,
                    virConnectAuthPtr auth G_GNUC_UNUSED,
-- 
2.31.1




[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