Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 7 +++++++
src/connect.c | 47 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 14e66e4..ee7bfdc 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -94,6 +94,13 @@
<arg name="flags" type="u" direction="in"/>
<arg name="storagePoolSources" type="s"
direction="out"/>
</method>
+ <method name="GetAllDomainStats">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectGetAllDoma...
+ <arg name="stats" type="u" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="records" type="a(sa{sv})"
direction="out"/>
+ </method>
<method name="GetCapabilities">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetCapabilit...
diff --git a/src/connect.c b/src/connect.c
index 1ef5c93..48db724 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -503,6 +503,52 @@ virtDBusConnectFindStoragePoolSources(GVariant *inArgs,
*outArgs = g_variant_new("(s)", ret);
}
+static void
+virtDBusConnectGetAllDomainStats(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(virDomainStatsRecordPtr) records = NULL;
+ guint stats;
+ gint nstats;
+ guint flags;
+ GVariant *gret;
+ GVariantBuilder builder;
+
+ g_variant_get(inArgs, "(uu)", &stats, &flags);
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ nstats = virConnectGetAllDomainStats(connect->connection,
+ stats, &records, flags);
+ if (nstats < 0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sa{sv})"));
+
+ for (gint i = 0; i < nstats; i++) {
+ const gchar* name;
+ GVariant *grecords;
+
+ g_variant_builder_open(&builder, G_VARIANT_TYPE("(sa{sv})"));
+ name = virDomainGetName(records[i]->dom);
+ grecords = virtDBusUtilTypedParamsToGVariant(records[i]->params,
+ records[i]->nparams);
+ g_variant_builder_add(&builder, "s", name);
+ g_variant_builder_add_value(&builder, grecords);
+ g_variant_builder_close(&builder);
+ }
+ gret = g_variant_builder_end(&builder);
+
+ *outArgs = g_variant_new_tuple(&gret, 1);
+}
+
static void
virtDBusConnectGetCPUModelNames(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -808,6 +854,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "DomainRestore", virtDBusConnectDomainRestoreFlags },
{ "DomainSaveImageDefineXML", virtDBusConnectDomainSaveImageDefineXML },
{ "FindStoragePoolSources", virtDBusConnectFindStoragePoolSources },
+ { "GetAllDomainStats", virtDBusConnectGetAllDomainStats },
{ "GetCapabilities", virtDBusConnectGetCapabilities },
{ "GetCPUModelNames", virtDBusConnectGetCPUModelNames },
{ "GetDomainCapabilities", virtDBusConnectGetDomainCapabilities },
--
2.15.0