mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 03:42:19 +00:00
virutil: Introduce virGetSCSIHostNameByParentaddr
Create the function from the code in getAdapterName() in order to return the "host#" name for the provided parentaddr values.
This commit is contained in:
parent
55f439599c
commit
beff5d4e1b
@ -2160,6 +2160,7 @@ virGetGroupList;
|
|||||||
virGetGroupName;
|
virGetGroupName;
|
||||||
virGetHostname;
|
virGetHostname;
|
||||||
virGetListenFDs;
|
virGetListenFDs;
|
||||||
|
virGetSCSIHostNameByParentaddr;
|
||||||
virGetSCSIHostNumber;
|
virGetSCSIHostNumber;
|
||||||
virGetSelfLastChanged;
|
virGetSelfLastChanged;
|
||||||
virGetUnprivSGIOSysfsPath;
|
virGetUnprivSGIOSysfsPath;
|
||||||
|
@ -519,22 +519,15 @@ getAdapterName(virStoragePoolSourceAdapter adapter)
|
|||||||
|
|
||||||
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) {
|
if (adapter.data.scsi_host.has_parent) {
|
||||||
|
virDevicePCIAddress addr = adapter.data.scsi_host.parentaddr;
|
||||||
unsigned int unique_id = adapter.data.scsi_host.unique_id;
|
unsigned int unique_id = adapter.data.scsi_host.unique_id;
|
||||||
|
|
||||||
if (virAsprintf(&parentaddr, "%04x:%02x:%02x.%01x",
|
if (!(name = virGetSCSIHostNameByParentaddr(addr.domain,
|
||||||
adapter.data.scsi_host.parentaddr.domain,
|
addr.bus,
|
||||||
adapter.data.scsi_host.parentaddr.bus,
|
addr.slot,
|
||||||
adapter.data.scsi_host.parentaddr.slot,
|
addr.function,
|
||||||
adapter.data.scsi_host.parentaddr.function) < 0)
|
unique_id)))
|
||||||
goto cleanup;
|
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 {
|
} else {
|
||||||
ignore_value(VIR_STRDUP(name, adapter.data.scsi_host.name));
|
ignore_value(VIR_STRDUP(name, adapter.data.scsi_host.name));
|
||||||
}
|
}
|
||||||
|
@ -1884,6 +1884,45 @@ virGetSCSIHostNumber(const char *adapter_name,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* virGetSCSIHostNameByParentaddr:
|
||||||
|
* @domain: The domain from the scsi_host parentaddr
|
||||||
|
* @bus: The bus from the scsi_host parentaddr
|
||||||
|
* @slot: The slot from the scsi_host parentaddr
|
||||||
|
* @function: The function from the scsi_host parentaddr
|
||||||
|
* @unique_id: The unique id value for parentaddr
|
||||||
|
*
|
||||||
|
* Generate a parentaddr and find the scsi_host host# for
|
||||||
|
* the provided parentaddr PCI address fields.
|
||||||
|
*
|
||||||
|
* Returns the "host#" string which must be free'd by
|
||||||
|
* the caller or NULL on error
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
virGetSCSIHostNameByParentaddr(unsigned int domain,
|
||||||
|
unsigned int bus,
|
||||||
|
unsigned int slot,
|
||||||
|
unsigned int function,
|
||||||
|
unsigned int unique_id)
|
||||||
|
{
|
||||||
|
char *name = NULL;
|
||||||
|
char *parentaddr = NULL;
|
||||||
|
|
||||||
|
if (virAsprintf(&parentaddr, "%04x:%02x:%02x.%01x",
|
||||||
|
domain, bus, slot, 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(parentaddr);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
/* virReadFCHost:
|
/* virReadFCHost:
|
||||||
* @sysfs_prefix: "fc_host" sysfs path, defaults to SYSFS_FC_HOST_PATH
|
* @sysfs_prefix: "fc_host" sysfs path, defaults to SYSFS_FC_HOST_PATH
|
||||||
* @host: Host number, E.g. 5 of "fc_host/host5"
|
* @host: Host number, E.g. 5 of "fc_host/host5"
|
||||||
@ -2262,6 +2301,17 @@ virGetSCSIHostNumber(const char *adapter_name ATTRIBUTE_UNUSED,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
virGetSCSIHostNameByParentaddr(unsigned int domain ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int bus ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int slot ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int function ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int unique_id ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
virReadFCHost(const char *sysfs_prefix ATTRIBUTE_UNUSED,
|
virReadFCHost(const char *sysfs_prefix ATTRIBUTE_UNUSED,
|
||||||
int host ATTRIBUTE_UNUSED,
|
int host ATTRIBUTE_UNUSED,
|
||||||
|
@ -177,6 +177,12 @@ int
|
|||||||
virGetSCSIHostNumber(const char *adapter_name,
|
virGetSCSIHostNumber(const char *adapter_name,
|
||||||
unsigned int *result)
|
unsigned int *result)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
char *
|
||||||
|
virGetSCSIHostNameByParentaddr(unsigned int domain,
|
||||||
|
unsigned int bus,
|
||||||
|
unsigned int slot,
|
||||||
|
unsigned int function,
|
||||||
|
unsigned int unique_id);
|
||||||
int virReadFCHost(const char *sysfs_prefix,
|
int virReadFCHost(const char *sysfs_prefix,
|
||||||
int host,
|
int host,
|
||||||
const char *entry,
|
const char *entry,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user