1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-09 01:18:00 +03:00

qemuBuildSCSIHostdevDevStr: Pass in backend alias

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-06-19 16:56:36 +02:00
parent 6cfcc0c68e
commit 78e8bb743b
3 changed files with 12 additions and 8 deletions

View File

@ -4641,11 +4641,11 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
char * char *
qemuBuildSCSIHostdevDevStr(const virDomainDef *def, qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev) virDomainHostdevDefPtr dev,
const char *backendAlias)
{ {
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int model = -1; int model = -1;
g_autofree char *driveAlias = NULL;
const char *contAlias; const char *contAlias;
model = qemuDomainFindSCSIControllerModel(def, dev->info); model = qemuDomainFindSCSIControllerModel(def, dev->info);
@ -4687,9 +4687,7 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
dev->info->addr.drive.unit); dev->info->addr.drive.unit);
} }
if (!(driveAlias = qemuAliasFromHostdev(dev))) virBufferAsprintf(&buf, ",drive=%s,id=%s", backendAlias, dev->info->alias);
return NULL;
virBufferAsprintf(&buf, ",drive=%s,id=%s", driveAlias, dev->info->alias);
if (dev->info->bootIndex) if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex); virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex);
@ -5073,6 +5071,7 @@ qemuBuildHostdevSCSICommandLine(virCommandPtr cmd,
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi; virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
g_autofree char *devstr = NULL; g_autofree char *devstr = NULL;
g_autofree char *drvstr = NULL; g_autofree char *drvstr = NULL;
g_autofree char *backendAlias = NULL;
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =
@ -5091,8 +5090,11 @@ qemuBuildHostdevSCSICommandLine(virCommandPtr cmd,
return -1; return -1;
virCommandAddArg(cmd, drvstr); virCommandAddArg(cmd, drvstr);
if (!(backendAlias = qemuAliasFromHostdev(hostdev)))
return -1;
virCommandAddArg(cmd, "-device"); virCommandAddArg(cmd, "-device");
if (!(devstr = qemuBuildSCSIHostdevDevStr(def, hostdev))) if (!(devstr = qemuBuildSCSIHostdevDevStr(def, hostdev, backendAlias)))
return -1; return -1;
virCommandAddArg(cmd, devstr); virCommandAddArg(cmd, devstr);

View File

@ -179,7 +179,9 @@ char *qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
virQEMUCapsPtr qemuCaps); virQEMUCapsPtr qemuCaps);
char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def, char *qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev); virDomainHostdevDefPtr dev,
const char *backendAlias);
char * char *
qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def, qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev, virDomainHostdevDefPtr dev,

View File

@ -2630,7 +2630,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
if (!(drivealias = qemuAliasFromHostdev(hostdev))) if (!(drivealias = qemuAliasFromHostdev(hostdev)))
goto cleanup; goto cleanup;
if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev))) if (!(devstr = qemuBuildSCSIHostdevDevStr(vm->def, hostdev, drivealias)))
goto cleanup; goto cleanup;
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)