mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
getAdapterName: Lookup stable scsi_host
If a parentaddr was provided in the XML, have getAdapterName lookup the stable address. This allows virStorageBackendSCSICheckPool() and virStorageBackendSCSIRefreshPool() to automagically find the scsi_host by its PCI address and unique_id
This commit is contained in:
parent
ef48a1b613
commit
ea37fb34a9
@ -547,9 +547,29 @@ static char *
|
|||||||
getAdapterName(virStoragePoolSourceAdapter adapter)
|
getAdapterName(virStoragePoolSourceAdapter adapter)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
|
char *parentaddr = NULL;
|
||||||
|
|
||||||
if (adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
|
if (adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
|
||||||
ignore_value(VIR_STRDUP(name, adapter.data.scsi_host.name));
|
if (adapter.data.scsi_host.has_parent) {
|
||||||
|
unsigned int unique_id = adapter.data.scsi_host.unique_id;
|
||||||
|
|
||||||
|
if (virAsprintf(&parentaddr, "%04x:%02x:%02x.%01x",
|
||||||
|
adapter.data.scsi_host.parentaddr.domain,
|
||||||
|
adapter.data.scsi_host.parentaddr.bus,
|
||||||
|
adapter.data.scsi_host.parentaddr.slot,
|
||||||
|
adapter.data.scsi_host.parentaddr.function) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
if (!(name = virFindSCSIHostByPCI(NULL, parentaddr,
|
||||||
|
unique_id))) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("Failed to find scsi_host using PCI '%s' "
|
||||||
|
"and unique_id='%u'"),
|
||||||
|
parentaddr, unique_id);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ignore_value(VIR_STRDUP(name, adapter.data.scsi_host.name));
|
||||||
|
}
|
||||||
} else if (adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
|
} else if (adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
|
||||||
if (!(name = virGetFCHostNameByWWN(NULL,
|
if (!(name = virGetFCHostNameByWWN(NULL,
|
||||||
adapter.data.fchost.wwnn,
|
adapter.data.fchost.wwnn,
|
||||||
@ -561,6 +581,8 @@ getAdapterName(virStoragePoolSourceAdapter adapter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(parentaddr);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user