[dbus PATCH 11/15] Implement GetJobStats method for Domain Interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Domain.xml |  6 ++++++
 src/domain.c                | 48 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index bda63f4..168820b 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -233,6 +233,12 @@
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/>
       <arg name="jobInfo" type="(sttttttttttt)" direction="out"/>
     </method>
+    <method name="GetJobStats">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobStats"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="stats" type="(sa{sv})" direction="out"/>
+    </method>
     <method name="GetMemoryParameters">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetMemoryParameters"/>
diff --git a/src/domain.c b/src/domain.c
index f611fbf..05ea680 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -1319,6 +1319,53 @@ virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
                              jobInfo->fileRemaining);
 }
 
+static void
+virtDBusDomainGetJobStats(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;
+    g_auto(virtDBusUtilTypedParams) params = { 0 };
+    guint flags;
+    const gchar *typeStr;
+    gint type;
+    GVariant *grecords;
+    GVariantBuilder builder;
+    GVariant *gret;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    if (virDomainGetJobStats(domain, &type, &params.params,
+                             &params.nparams, flags) < 0) {
+        return virtDBusUtilSetLastVirtError(error);
+    }
+
+    grecords = virtDBusUtilTypedParamsToGVariant(params.params, params.nparams);
+
+    typeStr = virtDBusDomainJobTypeToString(type);
+    if (!typeStr) {
+        g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
+                    "Can't format virDomainJobType '%d' to string.", type);
+        return;
+    }
+
+    g_variant_builder_init(&builder, G_VARIANT_TYPE("(sa{sv})"));
+    g_variant_builder_add(&builder, "s", typeStr);
+    g_variant_builder_add_value(&builder, grecords);
+    gret = g_variant_builder_end(&builder);
+
+    *outArgs = g_variant_new_tuple(&gret, 1);
+}
+
 static void
 virtDBusDomainGetMemoryParameters(GVariant *inArgs,
                                   GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -2367,6 +2414,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "GetInterfaceParameters", virtDBusDomainGetInterfaceParameters },
     { "GetIOThreadInfo", virtDBusDomainGetIOThreadInfo },
     { "GetJobInfo", virtDBusDomainGetJobInfo },
+    { "GetJobStats", virtDBusDomainGetJobStats },
     { "GetMemoryParameters", virtDBusDomainGetMemoryParameters },
     { "GetSchedulerParameters", virtDBusDomainGetSchedulerParameters },
     { "GetStats", virtDBusDomainGetStats },
-- 
2.15.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux