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. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/virstorageobj.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index a62d1d7..1623162 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -787,6 +787,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, @@ -821,18 +843,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)) -- 2.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list