render / rpms / libvirt

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