render / rpms / libvirt

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