Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 6 ++++++
src/connect.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 0c009cd..df91108 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -145,6 +145,12 @@
<arg name="flags" type="u" direction="in"/>
<arg name="networks" type="ao"
direction="out"/>
</method>
+ <method name="ListSecrets">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-secret.html#virConnectListAllSec...
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="secrets" type="ao"
direction="out"/>
+ </method>
<method name="ListStoragePools">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-storage.html#virConnectListAllSt...
diff --git a/src/connect.c b/src/connect.c
index e56089a..5732d8a 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -720,6 +720,42 @@ virtDBusConnectListNetworks(GVariant *inArgs,
*outArgs = g_variant_new_tuple(&gnetworks, 1);
}
+static void
+virtDBusConnectListSecrets(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(virSecretPtr) secrets = NULL;
+ guint flags;
+ GVariantBuilder builder;
+ GVariant *gsecrets;
+
+ g_variant_get(inArgs, "(u)", &flags);
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ if (virConnectListAllSecrets(connect->connection, &secrets, flags) < 0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("ao"));
+
+ for (gint i = 0; secrets[i]; i++) {
+ g_autofree gchar *path = NULL;
+ path = virtDBusUtilBusPathForVirSecret(secrets[i], connect->secretPath);
+
+ g_variant_builder_add(&builder, "o", path);
+ }
+
+ gsecrets = g_variant_builder_end(&builder);
+ *outArgs = g_variant_new_tuple(&gsecrets, 1);
+}
+
static void
virtDBusConnectListStoragePools(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1191,6 +1227,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "GetSysinfo", virtDBusConnectGetSysinfo },
{ "ListDomains", virtDBusConnectListDomains },
{ "ListNetworks", virtDBusConnectListNetworks },
+ { "ListSecrets", virtDBusConnectListSecrets },
{ "ListStoragePools", virtDBusConnectListStoragePools },
{ "NetworkCreateXML", virtDBusConnectNetworkCreateXML },
{ "NetworkDefineXML", virtDBusConnectNetworkDefineXML },
--
2.15.0