From: John Ferlan Date: Wed, 1 Apr 2015 18:05:54 +0000 (-0400) Subject: storage: Create virStoragePoolSourceMatchSingleHost X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9aced8c9d5cbcb5e1fc1f4e0f7d90a30c5e7a0d4;p=libvirt.git storage: Create virStoragePoolSourceMatchSingleHost Split out the nhost == 1 and hosts[0].name logic into a separate routine Signed-off-by: John Ferlan --- diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 351eea8895..f609f85762 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -2405,6 +2405,16 @@ matchSCSIAdapterParent(virStoragePoolObjPtr pool, return false; } +static bool +virStoragePoolSourceMatchSingleHost(virStoragePoolSourcePtr poolsrc, + virStoragePoolSourcePtr defsrc) +{ + if (poolsrc->nhost != 1 && defsrc->nhost != 1) + return false; + + return STREQ(poolsrc->hosts[0].name, defsrc->hosts[0].name); +} + static bool virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr matchpool, @@ -2413,10 +2423,7 @@ virStoragePoolSourceISCSIMatch(virStoragePoolObjPtr matchpool, 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)) + if (!virStoragePoolSourceMatchSingleHost(poolsrc, defsrc)) return false; if (STRNEQ_NULLABLE(poolsrc->initiator.iqn, defsrc->initiator.iqn))