From: Peter Krempa Date: Thu, 10 Sep 2020 13:33:45 +0000 (+0200) Subject: qemuDomainPrepareHostdev: Allocate backend nodenames in the prepare function X-Git-Tag: v6.8.0-rc1~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca495825a34d8cad12972805d1c15092aefb444b;p=thirdparty%2Flibvirt.git qemuDomainPrepareHostdev: Allocate backend nodenames in the prepare function Allocate the nodename in the setup function rather than in the command line generator. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d92b967419..c5c587b97d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5105,9 +5105,11 @@ qemuBuildHostdevSCSIAttachPrepare(virDomainHostdevDefPtr hostdev, switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: - if (!scsisrc->u.host.src && - !(scsisrc->u.host.src = virStorageSourceNew())) + if (!scsisrc->u.host.src) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("SCSI host device data structure was not initialized")); return NULL; + } if (!(devstr = qemuBuildSCSIHostHostdevDrvStr(hostdev))) return NULL; @@ -5130,7 +5132,6 @@ qemuBuildHostdevSCSIAttachPrepare(virDomainHostdevDefPtr hostdev, return NULL; } - src->nodestorage = g_strdup_printf("libvirt-%s-backend", hostdev->info->alias); ret->storageNodeName = src->nodestorage; *backendAlias = src->nodestorage; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 30f98fb650..4c902ff8ec 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10409,6 +10409,10 @@ qemuDomainPrepareHostdev(virDomainHostdevDefPtr hostdev, switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: + virObjectUnref(scsisrc->u.host.src); + if (!(scsisrc->u.host.src = virStorageSourceNew())) + return -1; + src = scsisrc->u.host.src; break; case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: @@ -10422,6 +10426,10 @@ qemuDomainPrepareHostdev(virDomainHostdevDefPtr hostdev, } if (src) { + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI)) { + src->nodestorage = g_strdup_printf("libvirt-%s-backend", hostdev->info->alias); + } + if (src->auth) { bool iscsiHasPS = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET); virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;