render / rpms / libvirt

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