提交 fc20b412 编写于 作者: J John Ferlan

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: NJohn Ferlan <jferlan@redhat.com>
上级 4864e377
......@@ -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,16 +2525,7 @@ 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;
}
}
if (!virStoragePoolSourceISCSIMatch(matchpool, def))
matchpool = NULL;
}
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册