]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Introduce virStoragePoolObjSourceMatchTypeDEVICE
authorJohn Ferlan <jferlan@redhat.com>
Wed, 5 Apr 2017 12:54:29 +0000 (08:54 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 13 Apr 2017 14:10:39 +0000 (10:10 -0400)
Refactor virStoragePoolObjSourceFindDuplicate into smaller units
separated by the "supported" pool source type. The ISCSI, FS,
LOGICAL, DISK, and ZFS pools can use "<source>... <device='%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.

src/conf/virstorageobj.c

index d74e3c7b3c17c6593034536cb3c56a65cdf53355..632fcde6ed4d35c558f983e48f015d3b105a28d2 100644 (file)
@@ -943,6 +943,28 @@ virStoragePoolObjSourceMatchTypeISCSI(virStoragePoolObjPtr pool,
 }
 
 
+static virStoragePoolObjPtr
+virStoragePoolObjSourceMatchTypeDEVICE(virStoragePoolObjPtr pool,
+                                       virStoragePoolDefPtr def)
+{
+    virStoragePoolObjPtr matchpool = NULL;
+
+    if (pool->def->type == VIR_STORAGE_POOL_ISCSI) {
+        if ((matchpool = virStoragePoolSourceFindDuplicateDevices(pool, def))) {
+            if (!virStoragePoolSourceISCSIMatch(matchpool, def))
+                return NULL;
+        }
+        return matchpool;
+    }
+
+    /* VIR_STORAGE_POOL_FS
+     * VIR_STORAGE_POOL_LOGICAL
+     * VIR_STORAGE_POOL_DISK
+     * VIR_STORAGE_POOL_ZFS */
+    return virStoragePoolSourceFindDuplicateDevices(pool, def);
+}
+
+
 int
 virStoragePoolObjSourceFindDuplicate(virConnectPtr conn,
                                      virStoragePoolObjListPtr pools,
@@ -977,18 +999,13 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr conn,
             break;
 
         case VIR_STORAGE_POOL_ISCSI:
-            matchpool = virStoragePoolSourceFindDuplicateDevices(pool, def);
-            if (matchpool) {
-                if (!virStoragePoolSourceISCSIMatch(matchpool, def))
-                    matchpool = NULL;
-            }
-            break;
         case VIR_STORAGE_POOL_FS:
         case VIR_STORAGE_POOL_LOGICAL:
         case VIR_STORAGE_POOL_DISK:
         case VIR_STORAGE_POOL_ZFS:
-            matchpool = virStoragePoolSourceFindDuplicateDevices(pool, def);
+            matchpool = virStoragePoolObjSourceMatchTypeDEVICE(pool, def);
             break;
+
         case VIR_STORAGE_POOL_SHEEPDOG:
             if (virStoragePoolSourceMatchSingleHost(&pool->def->source,
                                                     &def->source))