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 37daed0..137e67b 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -160,6 +160,12 @@ <arg name="flags" type="u" direction="in"/> <arg name="networks" type="ao" direction="out"/> </method> + <method name="ListNodeDevices"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-nodedev.html#virConnectListAllNodeDevices"/> + <arg name="flags" type="u" direction="in"/> + <arg name="devs" 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"/> diff --git a/src/connect.c b/src/connect.c index 08898c8..919172a 100644 --- a/src/connect.c +++ b/src/connect.c @@ -798,6 +798,43 @@ virtDBusConnectListNetworks(GVariant *inArgs, *outArgs = g_variant_new_tuple(&gnetworks, 1); } +static void +virtDBusConnectListNodeDevices(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(virNodeDevicePtr) devs = NULL; + guint flags; + GVariantBuilder builder; + GVariant *gdevs; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virConnectListAllNodeDevices(connect->connection, &devs, flags) < 0) + return virtDBusUtilSetLastVirtError(error); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + + for (gint i = 0; devs[i]; i++) { + g_autofree gchar *path = NULL; + path = virtDBusUtilBusPathForVirNodeDevice(devs[i], + connect->devPath); + + g_variant_builder_add(&builder, "o", path); + } + + gdevs = g_variant_builder_end(&builder); + *outArgs = g_variant_new_tuple(&gdevs, 1); +} + static void virtDBusConnectListNWFilters(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1632,6 +1669,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "ListDomains", virtDBusConnectListDomains }, { "ListNetworks", virtDBusConnectListNetworks }, + { "ListNodeDevices", virtDBusConnectListNodeDevices }, { "ListNWFilters", virtDBusConnectListNWFilters }, { "ListSecrets", virtDBusConnectListSecrets }, { "ListStoragePools", virtDBusConnectListStoragePools }, -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list