Move qemuDeviceDriveHostAlias from qemu_command and rename to qemuAssignDeviceDiskDriveAlias in qemu_alias. Also change the parameter to just be the disk->info.alias (e.g. srcalias) Includes some innocent bystanders that seem to need QEMU_DRIVE_HOST_PREFIX which requires include qemu_alias.h instead of qemu_command.h Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_alias.c | 17 +++++++++++++++++ src/qemu/qemu_alias.h | 4 ++++ src/qemu/qemu_command.c | 11 ----------- src/qemu/qemu_command.h | 1 - src/qemu/qemu_hotplug.c | 4 ++-- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_monitor_json.c | 2 +- src/qemu/qemu_monitor_text.c | 2 +- 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index d624071..b4a6e52 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -170,6 +170,23 @@ qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef, return virAsprintf(&controller->info.alias, "%s%d", prefix, controller->idx); } +/* qemuAssignDeviceDiskDriveAlias: + * @srcalias: Disk source alias + * + * Generate and return an alias for the device disk '-drive' + * + * Returns NULL or a string containing the alias + */ +char * +qemuAssignDeviceDiskDriveAlias(const char *srcalias) +{ + char *ret; + + if (virAsprintf(&ret, "%s%s", QEMU_DRIVE_HOST_PREFIX, srcalias) < 0) + return NULL; + return ret; +} + /* Our custom -drive naming scheme used with id= */ int diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h index e328a9b..972de55 100644 --- a/src/qemu/qemu_alias.h +++ b/src/qemu/qemu_alias.h @@ -30,6 +30,8 @@ # include "qemu_domain.h" # include "qemu_domain_address.h" +# define QEMU_DRIVE_HOST_PREFIX "drive-" + int qemuAssignDeviceChrAlias(virDomainDefPtr def, virDomainChrDefPtr chr, ssize_t idx); @@ -38,6 +40,8 @@ int qemuAssignDeviceControllerAlias(virDomainDefPtr domainDef, virQEMUCapsPtr qemuCaps, virDomainControllerDefPtr controller); +char *qemuAssignDeviceDiskDriveAlias(const char *srcalias); + int qemuAssignDeviceDiskAlias(virDomainDefPtr vmdef, virDomainDiskDefPtr def, virQEMUCapsPtr qemuCaps); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 71e9e63..c42ae16 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -287,17 +287,6 @@ qemuVirCommandGetDevSet(virCommandPtr cmd, int fd) } -char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk) -{ - char *ret; - - if (virAsprintf(&ret, "%s%s", - QEMU_DRIVE_HOST_PREFIX, disk->info.alias) < 0) - return NULL; - return ret; -} - - static int qemuBuildDeviceAddressStr(virBufferPtr buf, const virDomainDef *domainDef, diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index c4d0567..dcf9ba6 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -37,7 +37,6 @@ /* Config type for XML import/export conversions */ # define QEMU_CONFIG_FORMAT_ARGV "qemu-argv" -# define QEMU_DRIVE_HOST_PREFIX "drive-" # define QEMU_FSDEV_HOST_PREFIX "fsdev-" # define QEMU_BLOCK_IOTUNE_MAX 1000000000000000LL diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ae5203e..612b6ec 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -229,7 +229,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, if (qemuDomainPrepareDisk(driver, vm, disk, newsrc, false) < 0) goto cleanup; - if (!(driveAlias = qemuDeviceDriveHostAlias(disk))) + if (!(driveAlias = qemuAssignDeviceDiskDriveAlias(disk->info.alias))) goto error; qemuDomainObjEnterMonitor(driver, vm); @@ -345,7 +345,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps))) goto error; - if (!(drivealias = qemuDeviceDriveHostAlias(disk))) + if (!(drivealias = qemuAssignDeviceDiskDriveAlias(disk->info.alias))) goto error; if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps))) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c411dab..25dabb8 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -36,7 +36,7 @@ #include "qemu_domain.h" #include "qemu_process.h" #include "qemu_capabilities.h" -#include "qemu_command.h" +#include "qemu_alias.h" #include "qemu_cgroup.h" #include "qemu_hotplug.h" #include "qemu_blockjob.h" diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index bb426dc..a54ff8d 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -33,7 +33,7 @@ #include "qemu_monitor_text.h" #include "qemu_monitor_json.h" -#include "qemu_command.h" +#include "qemu_alias.h" #include "qemu_parse_command.h" #include "qemu_capabilities.h" #include "viralloc.h" diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 9295219..6c458e2 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -31,7 +31,7 @@ #include <string.h> #include "qemu_monitor_text.h" -#include "qemu_command.h" +#include "qemu_alias.h" #include "c-ctype.h" #include "c-strcasestr.h" #include "viralloc.h" -- 2.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list