Signed-off-by: Anya Harter <aharter(a)redhat.com>
---
data/org.libvirt.Connect.xml | 6 ++++++
src/connect.c | 38 ++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 7014a09..0604841 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -154,6 +154,12 @@
<arg name="flags" type="u" direction="in"/>
<arg name="domains" type="ao"
direction="out"/>
</method>
+ <method name="ListInterfaces">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-interface.html#virConnectListAll...
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="interfaces" type="ao"
direction="out"/>
+ </method>
<method name="ListNetworks">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-network.html#virConnectListAllNe...
diff --git a/src/connect.c b/src/connect.c
index b10533a..a3d002e 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -772,6 +772,43 @@ virtDBusConnectListDomains(GVariant *inArgs,
*outArgs = g_variant_new_tuple(&gdomains, 1);
}
+static void
+virtDBusConnectListInterfaces(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(virInterfacePtr) interfaces = NULL;
+ guint flags;
+ GVariantBuilder builder;
+ GVariant *ginterfaces;
+
+ g_variant_get(inArgs, "(u)", &flags);
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ if (virConnectListAllInterfaces(connect->connection, &interfaces, flags) <
0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("ao"));
+
+ for (gint i = 0; interfaces[i]; i++) {
+ g_autofree gchar *path = NULL;
+ path = virtDBusUtilBusPathForVirInterface(interfaces[i],
+ connect->interfacePath);
+
+ g_variant_builder_add(&builder, "o", path);
+ }
+
+ ginterfaces = g_variant_builder_end(&builder);
+ *outArgs = g_variant_new_tuple(&ginterfaces, 1);
+}
+
static void
virtDBusConnectListNetworks(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1767,6 +1804,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities },
{ "GetSysinfo", virtDBusConnectGetSysinfo },
{ "ListDomains", virtDBusConnectListDomains },
+ { "ListInterfaces", virtDBusConnectListInterfaces },
{ "ListNetworks", virtDBusConnectListNetworks },
{ "ListNodeDevices", virtDBusConnectListNodeDevices },
{ "ListNWFilters", virtDBusConnectListNWFilters },
--
2.17.1