Don't (re)generate the backend alias (alias of the -drive backend for now) internally but rather pass it in. Later on it will be replaced by the nodename when blockdev is used depending on the capabilities. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 14 ++++++++------ src/qemu/qemu_command.h | 4 +++- src/qemu/qemu_hotplug.c | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3d9479f863..200decd6e0 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4641,11 +4641,11 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, char * qemuBuildSCSIHostdevDevStr(const virDomainDef *def, - virDomainHostdevDefPtr dev) + virDomainHostdevDefPtr dev, + const char *backendAlias) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; int model = -1; - g_autofree char *driveAlias = NULL; const char *contAlias; model = qemuDomainFindSCSIControllerModel(def, dev->info); @@ -4687,9 +4687,7 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def, dev->info->addr.drive.unit); } - if (!(driveAlias = qemuAliasFromHostdev(dev))) - return NULL; - virBufferAsprintf(&buf, ",drive=%s,id=%s", driveAlias, dev->info->alias); + virBufferAsprintf(&buf, ",drive=%s,id=%s", backendAlias, dev->info->alias); if (dev->info->bootIndex) virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex); @@ -5073,6 +5071,7 @@ qemuBuildHostdevSCSICommandLine(virCommandPtr cmd, virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi; g_autofree char *devstr = NULL; g_autofree char *drvstr = NULL; + g_autofree char *backendAlias = NULL; if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = @@ -5091,8 +5090,11 @@ qemuBuildHostdevSCSICommandLine(virCommandPtr cmd, return -1; virCommandAddArg(cmd, drvstr); + if (!(backendAlias = qemuAliasFromHostdev(hostdev))) + return -1; + virCommandAddArg(cmd, "-device"); - if (!(devstr = qemuBuildSCSIHostdevDevStr(def, hostdev))) + if (!(devstr = qemuBuildSCSIHostdevDevStr(def, hostdev, backendAlias))) return -1; virCommandAddArg(cmd, devstr); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 55bc67072a..d0de27d9b0 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -179,7 +179,9 @@ char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, virQEMUCapsPtr qemuCaps); char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def, - virDomainHostdevDefPtr dev); + virDomainHostdevDefPtr dev, + const char *backendAlias); + char * qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, virDomainHostdevDefPtr dev, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index cbd4c88abe..fbbd6a533c 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2629,7 +2629,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver, if (!(drivealias = qemuAliasFromHostdev(hostdev))) goto cleanup; - if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev))) + if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, drivealias))) goto cleanup; if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) -- 2.26.2