[PATCH 1/4] conf: Introduce virStoragePoolObjSourceMatchTypeDIR

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

 



Refactor virStoragePoolObjSourceFindDuplicate into smaller units
separated by the "supported" pool source type. The DIR, GLUSTER,
and NETFS pools all can use "<source>... <dir='%s'/>... </source>".

Alter the logic slightly to return the matching pool or NULL rather
than setting matchpool = pool and break.  Easier to read that way.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/virstorageobj.c | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 34f2eb7..19898a3 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -697,6 +697,30 @@ virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr matchpool,
 }
 
 
+static virStoragePoolObjPtr
+virStoragePoolObjSourceMatchTypeDIR(virStoragePoolObjPtr pool,
+                                    virStoragePoolDefPtr def)
+{
+    if (pool->def->type == VIR_STORAGE_POOL_DIR) {
+        if (STREQ(pool->def->target.path, def->target.path))
+            return pool;
+    } else if (pool->def->type == VIR_STORAGE_POOL_GLUSTER) {
+        if (STREQ(pool->def->source.name, def->source.name) &&
+            STREQ_NULLABLE(pool->def->source.dir, def->source.dir) &&
+            virStoragePoolSourceMatchSingleHost(&pool->def->source,
+                                                &def->source))
+            return pool;
+    } else if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
+        if (STREQ(pool->def->source.dir, def->source.dir) &&
+            virStoragePoolSourceMatchSingleHost(&pool->def->source,
+                                                &def->source))
+            return pool;
+    }
+
+    return NULL;
+}
+
+
 int
 virStoragePoolObjSourceFindDuplicate(virConnectPtr conn,
                                      virStoragePoolObjListPtr pools,
@@ -723,23 +747,9 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr conn,
 
         switch ((virStoragePoolType)pool->def->type) {
         case VIR_STORAGE_POOL_DIR:
-            if (STREQ(pool->def->target.path, def->target.path))
-                matchpool = pool;
-            break;
-
         case VIR_STORAGE_POOL_GLUSTER:
-            if (STREQ(pool->def->source.name, def->source.name) &&
-                STREQ_NULLABLE(pool->def->source.dir, def->source.dir) &&
-                virStoragePoolSourceMatchSingleHost(&pool->def->source,
-                                                    &def->source))
-                matchpool = pool;
-            break;
-
         case VIR_STORAGE_POOL_NETFS:
-            if (STREQ(pool->def->source.dir, def->source.dir) &&
-                virStoragePoolSourceMatchSingleHost(&pool->def->source,
-                                                    &def->source))
-                matchpool = pool;
+            matchpool = virStoragePoolObjSourceMatchTypeDIR(pool, def);
             break;
 
         case VIR_STORAGE_POOL_SCSI:
-- 
2.9.3

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