提交 77911d30 编写于 作者: J Ján Tomko

Match scsi_host pools by parent address first

If both source adapters are specified by a parent address,
just comparing the address is faster and catches even addresses
that do not refer to valid adapters.
上级 d91c8e64
......@@ -2094,6 +2094,28 @@ getSCSIHostNumber(virStoragePoolSourceAdapter adapter,
VIR_FREE(name);
return ret;
}
static bool
matchSCSIAdapterParent(virStoragePoolObjPtr pool,
virStoragePoolDefPtr def)
{
virDevicePCIAddressPtr pooladdr =
&pool->def->source.adapter.data.scsi_host.parentaddr;
virDevicePCIAddressPtr defaddr =
&def->source.adapter.data.scsi_host.parentaddr;
int pool_unique_id =
pool->def->source.adapter.data.scsi_host.unique_id;
int def_unique_id =
def->source.adapter.data.scsi_host.unique_id;
if (pooladdr->domain == defaddr->domain &&
pooladdr->bus == defaddr->bus &&
pooladdr->slot == defaddr->slot &&
pooladdr->function == defaddr->function &&
pool_unique_id == def_unique_id) {
return true;
}
return false;
}
int
virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
......@@ -2143,6 +2165,13 @@ virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
unsigned int pool_hostnum, def_hostnum;
if (pool->def->source.adapter.data.scsi_host.has_parent &&
def->source.adapter.data.scsi_host.has_parent &&
matchSCSIAdapterParent(pool, def)) {
matchpool = pool;
break;
}
if (getSCSIHostNumber(pool->def->source.adapter,
&pool_hostnum) < 0 ||
getSCSIHostNumber(def->source.adapter, &def_hostnum) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册