[libvirt] [dbus PATCH 08/13] Implement SecretLookupByUUID method for Connect Interface

Katerina Koukiou kkoukiou at redhat.com
Wed May 9 14:59:33 UTC 2018


Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
---
 data/org.libvirt.Connect.xml |  6 ++++++
 src/connect.c                | 29 +++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 3aae9fe..cb70af9 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -223,6 +223,12 @@
       <arg name="params" type="a{sv}" direction="in"/>
       <arg name="flags" type="u" direction="in"/>
     </method>
+    <method name="SecretLookupByUUID">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-secret.html#virSecretLookupByUUIDString"/>
+      <arg name="uuid" 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#virStoragePoolLookupByName"/>
diff --git a/src/connect.c b/src/connect.c
index 6b96888..70b2ee8 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1151,6 +1151,34 @@ virtDBusConnectNodeSetMemoryParameters(GVariant *inArgs,
     }
 }
 
+static void
+virtDBusConnectSecretLookupByUUID(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;
+    const gchar *uuidstr;
+
+    g_variant_get(inArgs, "(s)", &uuidstr);
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    secret = virSecretLookupByUUIDString(connect->connection, uuidstr);
+    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,
@@ -1250,6 +1278,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats },
     { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel },
     { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters },
+    { "SecretLookupByUUID", virtDBusConnectSecretLookupByUUID },
     { "StoragePoolLookupByName", virtDBusConnectStoragePoolLookupByName },
     { "StoragePoolLookupByUUID", virtDBusConnectStoragePoolLookupByUUID },
     { 0 }
-- 
2.15.0




More information about the libvir-list mailing list