mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
storage: Rework getAdapterName to use adapter specific typedefs
Use the FCHost and SCSIHost adapter specific typedefs Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
0d130a2dde
commit
b129ac6aad
@ -176,33 +176,34 @@ virStoragePoolFCRefreshThread(void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
getAdapterName(virStoragePoolSourceAdapter adapter)
|
getAdapterName(virStoragePoolSourceAdapterPtr adapter)
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
char *parentaddr = 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) {
|
||||||
if (adapter.data.scsi_host.has_parent) {
|
virStorageAdapterSCSIHostPtr scsi_host = &adapter->data.scsi_host;
|
||||||
virPCIDeviceAddress addr = adapter.data.scsi_host.parentaddr;
|
|
||||||
unsigned int unique_id = adapter.data.scsi_host.unique_id;
|
|
||||||
|
|
||||||
if (!(name = virSCSIHostGetNameByParentaddr(addr.domain,
|
if (scsi_host->has_parent) {
|
||||||
addr.bus,
|
virPCIDeviceAddressPtr addr = &scsi_host->parentaddr;
|
||||||
addr.slot,
|
unsigned int unique_id = scsi_host->unique_id;
|
||||||
addr.function,
|
|
||||||
|
if (!(name = virSCSIHostGetNameByParentaddr(addr->domain,
|
||||||
|
addr->bus,
|
||||||
|
addr->slot,
|
||||||
|
addr->function,
|
||||||
unique_id)))
|
unique_id)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
ignore_value(VIR_STRDUP(name, adapter.data.scsi_host.name));
|
ignore_value(VIR_STRDUP(name, 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 = virVHBAGetHostByWWN(NULL,
|
virStorageAdapterFCHostPtr fchost = &adapter->data.fchost;
|
||||||
adapter.data.fchost.wwnn,
|
|
||||||
adapter.data.fchost.wwpn))) {
|
if (!(name = virVHBAGetHostByWWN(NULL, fchost->wwnn, fchost->wwpn))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("Failed to find SCSI host with wwnn='%s', "
|
_("Failed to find SCSI host with wwnn='%s', "
|
||||||
"wwpn='%s'"), adapter.data.fchost.wwnn,
|
"wwpn='%s'"), fchost->wwnn, fchost->wwpn);
|
||||||
adapter.data.fchost.wwpn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +459,7 @@ virStorageBackendSCSICheckPool(virStoragePoolObjPtr pool,
|
|||||||
|
|
||||||
*isActive = false;
|
*isActive = false;
|
||||||
|
|
||||||
if (!(name = getAdapterName(pool->def->source.adapter))) {
|
if (!(name = getAdapterName(&pool->def->source.adapter))) {
|
||||||
/* It's normal for the pool with "fc_host" type source
|
/* It's normal for the pool with "fc_host" type source
|
||||||
* adapter fails to get the adapter name, since the vHBA
|
* adapter fails to get the adapter name, since the vHBA
|
||||||
* the adapter based on might be not created yet.
|
* the adapter based on might be not created yet.
|
||||||
@ -498,7 +499,7 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
|
pool->def->allocation = pool->def->capacity = pool->def->available = 0;
|
||||||
|
|
||||||
if (!(name = getAdapterName(pool->def->source.adapter)))
|
if (!(name = getAdapterName(&pool->def->source.adapter)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virSCSIHostGetNumber(name, &host) < 0)
|
if (virSCSIHostGetNumber(name, &host) < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user