[PATCH 2/3] storage: driver: Split out code fixing pool state after deactivation

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

 



After a pool is made inactive the definition objects need to be updated
(if a new definition is prepared) and transient pools need to be
completely removed. Split out the code doing these steps into a separate
function for later reuse.
---
 src/storage/storage_driver.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 61c5e7eff..618b640a2 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -77,6 +77,31 @@ static void storageDriverUnlock(void)
     virMutexUnlock(&driver->lock);
 }

+
+/**
+ * virStoragePoolUpdateInactive:
+ * @poolptr: pointer to a variable holding the pool object pointer
+ *
+ * This function is supposed to be called after a pool becomes inactive. The
+ * function switches to the new config object for persistent pools. Inactive
+ * pools are removed.
+ */
+static void
+virStoragePoolUpdateInactive(virStoragePoolObjPtr *poolptr)
+{
+    virStoragePoolObjPtr pool = *poolptr;
+
+    if (pool->configFile == NULL) {
+        virStoragePoolObjRemove(&driver->pools, pool);
+        *poolptr = NULL;
+    } else if (pool->newDef) {
+        virStoragePoolDefFree(pool->def);
+        pool->def = pool->newDef;
+        pool->newDef = NULL;
+    }
+}
+
+
 static void
 storagePoolUpdateState(virStoragePoolObjPtr pool)
 {
@@ -1071,14 +1096,7 @@ storagePoolDestroy(virStoragePoolPtr obj)

     pool->active = false;

-    if (pool->configFile == NULL) {
-        virStoragePoolObjRemove(&driver->pools, pool);
-        pool = NULL;
-    } else if (pool->newDef) {
-        virStoragePoolDefFree(pool->def);
-        pool->def = pool->newDef;
-        pool->newDef = NULL;
-    }
+    virStoragePoolUpdateInactive(&pool);

     ret = 0;

@@ -1200,10 +1218,8 @@ storagePoolRefresh(virStoragePoolPtr obj,
                                                 0);
         pool->active = false;

-        if (pool->configFile == NULL) {
-            virStoragePoolObjRemove(&driver->pools, pool);
-            pool = NULL;
-        }
+        virStoragePoolUpdateInactive(&pool);
+
         goto cleanup;
     }

-- 
2.12.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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