
On Thu, Apr 26, 2018 at 04:54:13PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com> --- data/org.libvirt.Connect.xml | 7 +++++++ src/connect.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 62a65ae..abb2dbc 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -196,6 +196,13 @@ <arg name="flags" type="u" direction="in"/> <arg name="memoryParameters" type="a{sv}" direction="out"/> </method> + <method name="NodeGetMemoryStats"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetMemoryStats"/> + <arg name="cellNum" type="i" direction="in"/>
I think we don't have to export this argument and instead always return all stats, so we will call virNodeGetMemoryStats with VIR_NODE_MEMORY_STATS_ALL_CELLS as cellNum.
+ <arg name="flags" type="u" direction="in"/> + <arg name="stats" type="a{st}" direction="out"/> + </method> <signal name="DomainEvent"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/> diff --git a/src/connect.c b/src/connect.c index 8a168f4..27355d3 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1003,6 +1003,47 @@ virtDBusConnectNodeGetMemoryParameters(GVariant *inArgs, *outArgs = g_variant_new_tuple(&grecords, 1); }
+static void +virtDBusConnectNodeGetMemoryStats(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_autofree virNodeMemoryStatsPtr params = NULL; + gint nparams = 0; + gint cellNum; + guint flags; + gint ret; + GVariantBuilder builder; + GVariant *res; + + g_variant_get(inArgs, "(iu)", &cellNum, &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + ret = virNodeGetMemoryStats(connect->connection, cellNum, NULL, + &nparams, flags);
We should check the return value and set an error if the API fails. Pavel