Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 7 +++++++
src/connect.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index cb70af9..fc29165 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -229,6 +229,13 @@
<arg name="uuid" type="s" direction="in"/>
<arg name="secret" type="o" direction="out"/>
</method>
+ <method name="SecretLookupByUsage">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretLookupByUsa...
+ <arg name="usageType" type="i"
direction="in"/>
+ <arg name="usageID" type="s" direction="in"/>
+ <arg name="secret" type="o" direction="out"/>
+ </method>
<method name="StoragePoolLookupByName">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-storage.html#virStoragePoolLooku...
diff --git a/src/connect.c b/src/connect.c
index 70b2ee8..3ef068f 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1179,6 +1179,35 @@ virtDBusConnectSecretLookupByUUID(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
+static void
+virtDBusConnectSecretLookupByUsage(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath G_GNUC_UNUSED,
+ gpointer userData,
+ GVariant **outArgs,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autoptr(virSecret) secret = NULL;
+ g_autofree gchar *path = NULL;
+ gint usageType;
+ const gchar *usageID;
+
+ g_variant_get(inArgs, "(i&s)", &usageType, &usageID);
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ secret = virSecretLookupByUsage(connect->connection, usageType, usageID);
+ if (!secret)
+ return virtDBusUtilSetLastVirtError(error);
+
+ path = virtDBusUtilBusPathForVirSecret(secret, connect->secretPath);
+
+ *outArgs = g_variant_new("(o)", path);
+}
+
static void
virtDBusConnectStoragePoolLookupByName(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1279,6 +1308,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel },
{ "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters },
{ "SecretLookupByUUID", virtDBusConnectSecretLookupByUUID },
+ { "SecretLookupByUsage", virtDBusConnectSecretLookupByUsage },
{ "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
{ "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID },
{ 0 }
--
2.15.0