Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Domain.xml | 14 ++++-----
src/domain.c | 75 ++++++++++++++++++++++-----------------------
2 files changed, 44 insertions(+), 45 deletions(-)
diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index ecd3f04..651e517 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -45,6 +45,13 @@
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainDestroyFlag...
<arg name="flags" type="u" direction="in"/>
</method>
+ <method name="GetStats">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainListGetStat...
+ <arg name="stats" type="u" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="records" type="a{sv}"
direction="out"/>
+ </method>
<method name="GetVcpus">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetVcpusFla...
@@ -57,13 +64,6 @@
<arg name="flags" type="u" direction="in"/>
<arg name="xml" type="s" direction="out"/>
</method>
- <method name="GetStats">
- <annotation name="org.gtk.GDBus.DocString"
- value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainListGetStat...
- <arg name="stats" type="u" direction="in"/>
- <arg name="flags" type="u" direction="in"/>
- <arg name="records" type="a{sv}"
direction="out"/>
- </method>
<method name="Shutdown">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainShutdownFla...
diff --git a/src/domain.c b/src/domain.c
index f797627..2178352 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -264,6 +264,42 @@ virtDBusDomainDestroy(GVariant *inArgs,
virtDBusUtilSetLastVirtError(error);
}
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainStatsRecordPtr, virDomainStatsRecordListFree);
+
+static void
+virtDBusDomainGetStats(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath,
+ gpointer userData,
+ GVariant **outArgs,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autoptr(virDomain) domain = NULL;
+ virDomainPtr domains[2];
+ g_autoptr(virDomainStatsRecordPtr) records = NULL;
+ guint stats;
+ guint flags;
+ GVariant *grecords;
+
+ g_variant_get(inArgs, "(uu)", &stats, &flags);
+
+ domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+ if (!domain)
+ return;
+
+ domains[0] = domain;
+ domains[1] = NULL;
+
+ if (virDomainListGetStats(domains, stats, &records, flags) != 1)
+ return virtDBusUtilSetLastVirtError(error);
+
+ grecords = virtDBusUtilTypedParamsToGVariant(records[0]->params,
+ records[0]->nparams);
+
+ *outArgs = g_variant_new_tuple(&grecords, 1);
+}
static void
virtDBusDomainGetVcpus(GVariant *inArgs,
@@ -320,43 +356,6 @@ virtDBusDomainGetXMLDesc(GVariant *inArgs,
*outArgs = g_variant_new("(s)", xml);
}
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainStatsRecordPtr, virDomainStatsRecordListFree);
-
-static void
-virtDBusDomainGetStats(GVariant *inArgs,
- GUnixFDList *inFDs G_GNUC_UNUSED,
- const gchar *objectPath,
- gpointer userData,
- GVariant **outArgs,
- GUnixFDList **outFDs G_GNUC_UNUSED,
- GError **error)
-{
- virtDBusConnect *connect = userData;
- g_autoptr(virDomain) domain = NULL;
- virDomainPtr domains[2];
- g_autoptr(virDomainStatsRecordPtr) records = NULL;
- guint stats;
- guint flags;
- GVariant *grecords;
-
- g_variant_get(inArgs, "(uu)", &stats, &flags);
-
- domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
- if (!domain)
- return;
-
- domains[0] = domain;
- domains[1] = NULL;
-
- if (virDomainListGetStats(domains, stats, &records, flags) != 1)
- return virtDBusUtilSetLastVirtError(error);
-
- grecords = virtDBusUtilTypedParamsToGVariant(records[0]->params,
- records[0]->nparams);
-
- *outArgs = g_variant_new_tuple(&grecords, 1);
-}
-
static void
virtDBusDomainShutdown(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -506,9 +505,9 @@ static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] = {
static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
{ "Create", virtDBusDomainCreate },
{ "Destroy", virtDBusDomainDestroy },
+ { "GetStats", virtDBusDomainGetStats },
{ "GetVcpus", virtDBusDomainGetVcpus },
{ "GetXMLDesc", virtDBusDomainGetXMLDesc },
- { "GetStats", virtDBusDomainGetStats },
{ "Shutdown", virtDBusDomainShutdown },
{ "Reboot", virtDBusDomainReboot },
{ "Reset", virtDBusDomainReset },
--
2.15.0