mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
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.
This commit is contained in:
parent
d91c8e640b
commit
77911d305d
@ -2094,6 +2094,28 @@ getSCSIHostNumber(virStoragePoolSourceAdapter adapter,
|
|||||||
VIR_FREE(name);
|
VIR_FREE(name);
|
||||||
return ret;
|
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
|
int
|
||||||
virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
|
virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
|
||||||
@ -2143,6 +2165,13 @@ virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
|
|||||||
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
|
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
|
||||||
unsigned int pool_hostnum, def_hostnum;
|
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,
|
if (getSCSIHostNumber(pool->def->source.adapter,
|
||||||
&pool_hostnum) < 0 ||
|
&pool_hostnum) < 0 ||
|
||||||
getSCSIHostNumber(def->source.adapter, &def_hostnum) < 0)
|
getSCSIHostNumber(def->source.adapter, &def_hostnum) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user