libvirt/SOURCES/libvirt-qemu-Split-out-initialization-of-secrets-for-iscsi-hostdevs.patch
2021-10-08 13:11:20 +00:00

81 lines
3.7 KiB
Diff

From 1c5d21527ce3cb5182434d206d589a85b1901b42 Mon Sep 17 00:00:00 2001
Message-Id: <1c5d21527ce3cb5182434d206d589a85b1901b42@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:11:52 +0100
Subject: [PATCH] qemu: Split out initialization of secrets for 'iscsi'
hostdevs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Currently we don't have infrastructure to remember the secret aliases
for hostdevs. Since an upcoming patch is going to change aliases for
the disks, initialize the iscsi hostdevs separately so that we can keep
the alias. At the same time let's use qemuAliasForSecret instead of
qemuDomainGetSecretAESAlias when unplugging the iscsi hostdev.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 740dd1a4e5ce81e5b0be855dd413dd7eec81ccd3)
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
Message-Id: <f4157def83aa59b7432c6e0714d621ff5b2bed4a.1584391726.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_domain.c | 25 +++++++++++++++++++++++--
src/qemu/qemu_hotplug.c | 2 +-
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 897e21726a..0047a1d316 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1848,8 +1848,29 @@ qemuDomainSecretHostdevPrepare(qemuDomainObjPrivatePtr priv,
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
src->auth) {
- if (qemuDomainSecretStorageSourcePrepare(priv, src,
- hostdev->info->alias, NULL) < 0)
+ bool iscsiHasPS = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET);
+ virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI;
+ qemuDomainStorageSourcePrivatePtr srcPriv;
+
+ if (!(src->privateData = qemuDomainStorageSourcePrivateNew()))
+ return -1;
+
+ srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
+
+ if (!qemuDomainSupportsEncryptedSecret(priv) || !iscsiHasPS) {
+ srcPriv->secinfo = qemuDomainSecretInfoNewPlain(usageType,
+ src->auth->username,
+ &src->auth->seclookupdef);
+ } else {
+ srcPriv->secinfo = qemuDomainSecretAESSetupFromSecret(priv,
+ hostdev->info->alias,
+ usageType,
+ src->auth->username,
+ &src->auth->seclookupdef,
+ false);
+ }
+
+ if (!srcPriv->secinfo)
return -1;
}
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 12bc1f9dd5..a473bab3e1 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4438,7 +4438,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET) &&
qemuDomainStorageSourceHasAuth(iscsisrc->src)) {
- if (!(objAlias = qemuDomainGetSecretAESAlias(hostdev->info->alias, false)))
+ if (!(objAlias = qemuAliasForSecret(hostdev->info->alias, NULL)))
return -1;
}
--
2.25.1