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 f690bab..791e1f5 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -161,6 +161,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 304a56f..9be8264 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -801,6 +801,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,
@@ -1797,6 +1834,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "GetSysinfo", virtDBusConnectGetSysinfo },
{ "InterfaceDefineXML", virtDBusConnectInterfaceDefineXML },
{ "ListDomains", virtDBusConnectListDomains },
+ { "ListInterfaces", virtDBusConnectListInterfaces },
{ "ListNetworks", virtDBusConnectListNetworks },
{ "ListNodeDevices", virtDBusConnectListNodeDevices },
{ "ListNWFilters", virtDBusConnectListNWFilters },
--
2.17.1