Allocate the nodename in the setup function rather than in the command
line generator.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 7 ++++---
src/qemu/qemu_domain.c | 8 ++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
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 a751d0c205..d570ba892b 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;
--
2.26.2