Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- 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 243ef35..a78a87d 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -153,6 +153,12 @@ <arg name="flags" type="u" direction="in"/> <arg name="networks" type="ao" direction="out"/> </method> + <method name="ListNWFilters"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-nwfilter.html#virConnectListAllNWFilters"/> + <arg name="flags" type="u" direction="in"/> + <arg name="nwfilters" type="ao" direction="out"/> + </method> <method name="ListSecrets"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-secret.html#virConnectListAllSecrets"/> diff --git a/src/connect.c b/src/connect.c index 136f7ae..ff1120e 100644 --- a/src/connect.c +++ b/src/connect.c @@ -770,6 +770,43 @@ virtDBusConnectListNetworks(GVariant *inArgs, *outArgs = g_variant_new_tuple(&gnetworks, 1); } +static void +virtDBusConnectListNWFilters(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(virNWFilterPtr) nwfilters = NULL; + guint flags; + GVariantBuilder builder; + GVariant *gnwfilters; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virConnectListAllNWFilters(connect->connection, &nwfilters, flags) < 0) + return virtDBusUtilSetLastVirtError(error); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + + for (gint i = 0; nwfilters[i]; i++) { + g_autofree gchar *path = NULL; + path = virtDBusUtilBusPathForVirNWFilter(nwfilters[i], + connect->nwfilterPath); + + g_variant_builder_add(&builder, "o", path); + } + + gnwfilters = g_variant_builder_end(&builder); + *outArgs = g_variant_new_tuple(&gnwfilters, 1); +} + static void virtDBusConnectListSecrets(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1364,6 +1401,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "ListDomains", virtDBusConnectListDomains }, { "ListNetworks", virtDBusConnectListNetworks }, + { "ListNWFilters", virtDBusConnectListNWFilters }, { "ListSecrets", virtDBusConnectListSecrets }, { "ListStoragePools", virtDBusConnectListStoragePools }, { "NetworkCreateXML", virtDBusConnectNetworkCreateXML }, -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list