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

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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-09-10 15:33:45 +02:00
parent c17e4907fe
commit ca495825a3
2 changed files with 12 additions and 3 deletions

View File

@ -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;

View File

@ -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;