Commit 5aace6c3 authored by Anya Harter's avatar Anya Harter Committed by Katerina Koukiou

Implement ListInterfaces method for Connect Interface

Signed-off-by: 's avatarAnya Harter <aharter@redhat.com>
Reviewed-by: 's avatarKaterina Koukiou <kkoukiou@redhat.com>
parent 5dbc7822
......@@ -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#virConnectListAllInterfaces"/>
<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#virConnectListAllNetworks"/>
......
......@@ -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 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment