[dbus PATCH 09/13] Implement SecretLookupByUsage method for Connect Interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 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#virSecretLookupByUsage"/>
+      <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#virStoragePoolLookupByName"/>
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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux