Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 7 +++++++
src/connect.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index e5504f7..3ef965d 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-host.html#virConnectGetAllDomain...
+ <arg name="stats" type="u" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="records" type="av"
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 4e64238..e774fa4 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -503,6 +503,45 @@ 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 *grecords;
+ 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("av"));
+ for (gint i = 0; i < nstats; i++) {
+ grecords = virtDBusUtilTypedParamsToGVariant(records[i]->params,
+ records[i]->nparams);
+ g_variant_builder_add(&builder, "v", grecords);
+ }
+ gret = g_variant_builder_end(&builder);
+
+ *outArgs = g_variant_new_tuple(&gret, 1);
+}
+
static void
virtDBusConnectGetSysinfo(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -741,6 +780,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "DomainRestore", virtDBusConnectDomainRestoreFlags },
{ "DomainSaveImageDefineXML", virtDBusConnectDomainSaveImageDefineXML },
{ "FindStoragePoolSources", virtDBusConnectFindStoragePoolSources },
+ { "GetAllDomainStats", virtDBusConnectGetAllDomainStats },
{ "GetCapabilities", virtDBusConnectGetCapabilities },
{ "GetSysinfo", virtDBusConnectGetSysinfo },
{ "ListDomains", virtDBusConnectListDomains },
--
2.15.0