
On Tue, Jul 19, 2016 at 10:30:46AM -0400, John Ferlan wrote:
Rather than open code build the drive alias command in multiple places, use the helper to ensure consistency.
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/qemu/qemu_command.c | 12 ++++++++++-- src/qemu/qemu_driver.c | 3 +-- src/qemu/qemu_hotplug.c | 3 +-- src/qemu/qemu_migration.c | 9 +++------ src/qemu/qemu_monitor_json.c | 2 +- src/qemu/qemu_monitor_text.c | 8 ++++++-- 6 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index affd0b0..482f993 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1245,7 +1245,11 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, }
if (emitDeviceSyntax) { - virBufferAsprintf(&opt, ",id=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias); + char *drivealias = qemuAssignDeviceDiskDriveAlias(disk->info.alias); + if (!drivealias) + goto error; + virBufferAsprintf(&opt, ",id=%s", drivealias); + VIR_FREE(drivealias);
Creating a separate 'qemuAliasDiskDriveBuf' would get rid of the extra free and error handling. On the other hand, this way both 'id' and its value are on the same line. Jan