qemu: Introduce qemuAliasFromHostdev

Introduce a common API to generate the alias for a host device
This commit is contained in:
John Ferlan 2016-07-18 13:19:02 -04:00
parent 97ca6eed9a
commit 647bc753d4
2 changed files with 25 additions and 0 deletions

View File

@ -493,6 +493,29 @@ qemuAliasDiskDriveSkipPrefix(const char *dev_name)
}
/* qemuAliasFromHostdev
* @hostdev: Pointer to host device
*
* Generate and return a string containing a drive alias
*/
char *
qemuAliasFromHostdev(const virDomainHostdevDef *hostdev)
{
char *ret;
if (!hostdev->info->alias) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("hostdev does not have an alias"));
return NULL;
}
ignore_value(virAsprintf(&ret, "%s-%s",
virDomainDeviceAddressTypeToString(hostdev->info->type),
hostdev->info->alias));
return ret;
}
/* qemuDomainGetMasterKeyAlias:
*
* Generate and return the masterKey alias

View File

@ -69,6 +69,8 @@ char *qemuAliasFromDisk(const virDomainDiskDef *disk);
const char *qemuAliasDiskDriveSkipPrefix(const char *dev_name);
char *qemuAliasFromHostdev(const virDomainHostdevDef *hostdev);
char *qemuDomainGetMasterKeyAlias(void);
char *qemuDomainGetSecretAESAlias(const char *srcalias,