Blame SOURCES/libvirt-qemu-Introduce-another-helper-for-creating-alias-for-a-secret-object.patch

fbe740
From 2ca069dae766b266e12f1feb9f9ca9d3f2deb7bb Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <2ca069dae766b266e12f1feb9f9ca9d3f2deb7bb@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Mon, 16 Mar 2020 22:11:49 +0100
fbe740
Subject: [PATCH] qemu: Introduce another helper for creating alias for a
fbe740
 'secret' object
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
qemuAliasForSecret is meant as a replacement qemuDomainGetSecretAESAlias
fbe740
with saner API. The sub-type we are creating the alias for is passed in
fbe740
as a string rather than the unflexible 'isLuks' boolean.
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
(cherry picked from commit bb2a81df21710ed8258854e0dc2b3c2e923831f2)
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
fbe740
Message-Id: <fe8144c851d9e849617ae66b99a8605e75697809.1584391726.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/qemu/qemu_alias.c | 17 +++++++++++++++++
fbe740
 src/qemu/qemu_alias.h |  3 +++
fbe740
 2 files changed, 20 insertions(+)
fbe740
fbe740
diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c
fbe740
index 93bdcb7548..50ad054c6c 100644
fbe740
--- a/src/qemu/qemu_alias.c
fbe740
+++ b/src/qemu/qemu_alias.c
fbe740
@@ -792,6 +792,23 @@ qemuDomainGetSecretAESAlias(const char *srcalias,
fbe740
 }
fbe740
 
fbe740
 
fbe740
+/* qemuAliasForSecret:
fbe740
+ * @parentalias: alias of the parent object
fbe740
+ * @obj: optional sub-object of the parent device the secret is for
fbe740
+ *
fbe740
+ * Generate alias for a secret object used by @parentalias device or one of
fbe740
+ * the dependencies of the device described by @obj.
fbe740
+ */
fbe740
+char *
fbe740
+qemuAliasForSecret(const char *parentalias,
fbe740
+                   const char *obj)
fbe740
+{
fbe740
+    if (obj)
fbe740
+        return g_strdup_printf("%s-%s-secret0", parentalias, obj);
fbe740
+    else
fbe740
+        return g_strdup_printf("%s-secret0", parentalias);
fbe740
+}
fbe740
+
fbe740
 /* qemuAliasTLSObjFromSrcAlias
fbe740
  * @srcAlias: Pointer to a source alias string
fbe740
  *
fbe740
diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h
fbe740
index ae2fce16bc..645956d024 100644
fbe740
--- a/src/qemu/qemu_alias.h
fbe740
+++ b/src/qemu/qemu_alias.h
fbe740
@@ -86,6 +86,9 @@ char *qemuDomainGetMasterKeyAlias(void);
fbe740
 char *qemuDomainGetSecretAESAlias(const char *srcalias,
fbe740
                                   bool isLuks);
fbe740
 
fbe740
+char *qemuAliasForSecret(const char *parentalias,
fbe740
+                         const char *obj);
fbe740
+
fbe740
 char *qemuAliasTLSObjFromSrcAlias(const char *srcAlias)
fbe740
     ATTRIBUTE_NONNULL(1);
fbe740
 
fbe740
-- 
fbe740
2.25.1
fbe740