1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

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 "<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.
This commit is contained in:
John Ferlan 2017-04-05 08:54:29 -04:00
parent 2811e29e10
commit f84b89fb19

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