render / rpms / libvirt

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