From: John Ferlan Date: Wed, 5 Apr 2017 12:54:29 +0000 (-0400) Subject: conf: Introduce virStoragePoolObjSourceMatchTypeDEVICE X-Git-Tag: v3.3.0-rc1~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f84b89fb1993cc9709624d0e1b21e5faa8f53b4e;p=thirdparty%2Flibvirt.git conf: Introduce virStoragePoolObjSourceMatchTypeDEVICE Refactor virStoragePoolObjSourceFindDuplicate into smaller units separated by the "supported" pool source type. The ISCSI, FS, LOGICAL, DISK, and ZFS pools can use "... ... ". Alter the logic slightly to return the matching pool or NULL rather than setting matchpool = pool and break. Easier to read that way. --- diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index d74e3c7b3c..632fcde6ed 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -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))