mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
storage: Refactor iSCSI Source matching
Create a separate iSCSI Source matching subroutine. Makes the calling code a bit cleaner as well as sets up for future patches which need to do better source hosts[0].name processing/checking. As part of the effort the logic will be inverted from a multi-level if statement to a series of single level checks for better readability and further separation Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
4864e377c9
commit
fc20b41271
@ -2406,6 +2406,26 @@ matchSCSIAdapterParent(virStoragePoolObjPtr pool,
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr matchpool,
|
||||
virStoragePoolDefPtr def)
|
||||
{
|
||||
virStoragePoolSourcePtr poolsrc = &matchpool->def->source;
|
||||
virStoragePoolSourcePtr defsrc = &def->source;
|
||||
|
||||
if (poolsrc->nhost != 1 && defsrc->nhost != 1)
|
||||
return false;
|
||||
|
||||
if (STRNEQ(poolsrc->hosts[0].name, defsrc->hosts[0].name))
|
||||
return false;
|
||||
|
||||
if (STRNEQ_NULLABLE(poolsrc->initiator.iqn, defsrc->initiator.iqn))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virStoragePoolSourceFindDuplicate(virConnectPtr conn,
|
||||
virStoragePoolObjListPtr pools,
|
||||
@ -2505,17 +2525,8 @@ virStoragePoolSourceFindDuplicate(virConnectPtr conn,
|
||||
case VIR_STORAGE_POOL_ISCSI:
|
||||
matchpool = virStoragePoolSourceFindDuplicateDevices(pool, def);
|
||||
if (matchpool) {
|
||||
if (matchpool->def->source.nhost == 1 && def->source.nhost == 1) {
|
||||
if (STREQ(matchpool->def->source.hosts[0].name, def->source.hosts[0].name)) {
|
||||
if ((matchpool->def->source.initiator.iqn) && (def->source.initiator.iqn)) {
|
||||
if (STREQ(matchpool->def->source.initiator.iqn, def->source.initiator.iqn))
|
||||
break;
|
||||
matchpool = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
matchpool = NULL;
|
||||
if (!virStoragePoolSourceISCSIMatch(matchpool, def))
|
||||
matchpool = NULL;
|
||||
}
|
||||
break;
|
||||
case VIR_STORAGE_POOL_FS:
|
||||
|
Loading…
x
Reference in New Issue
Block a user