libvirt/SOURCES/libvirt-qemu-Introduce-another-helper-for-creating-alias-for-a-secret-object.patch
2021-09-10 11:57:33 +00:00

71 lines
2.4 KiB
Diff

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