Signed-off-by: Katerina Koukiou <kkouk...@redhat.com>
---
 data/org.libvirt.Domain.xml |  5 +++++
 src/domain.c                | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 83e37bc..2e0339b 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -62,6 +62,11 @@
       <arg name="xml" type="s" direction="in"/>
       <arg name="flags" type="u" direction="in"/>
     </method>
+    <method name="GetJobInfo">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See 
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/>
+      <arg name="jobInfo" type="(sttttttttttt)" direction="out"/>
+    </method>
     <method name="GetStats">
       <annotation name="org.gtk.GDBus.DocString"
         value="See 
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainListGetStats"/>
diff --git a/src/domain.c b/src/domain.c
index bf352a7..e80749b 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -396,6 +396,40 @@ virtDBusDomainDetachDevice(GVariant *inArgs,
         return virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
+                         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_autofree virDomainJobInfoPtr jobInfo = NULL;
+    const gchar *jobTypeStr;
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    jobInfo = g_new0(virDomainJobInfo, 1);
+    if (virDomainGetJobInfo(domain, jobInfo) == -1)
+        return virtDBusUtilSetLastVirtError(error);
+
+    jobTypeStr = virtDBusDomainJobTypeToString(jobInfo->type);
+    if (!jobTypeStr)
+        return;
+    *outArgs = g_variant_new("((sttttttttttt))", jobTypeStr,
+                             jobInfo->timeElapsed, jobInfo->timeRemaining,
+                             jobInfo->dataTotal, jobInfo->dataProcessed,
+                             jobInfo->dataRemaining, jobInfo->memTotal,
+                             jobInfo->memProcessed, jobInfo->memRemaining,
+                             jobInfo->fileTotal, jobInfo->fileProcessed,
+                             jobInfo->fileRemaining);
+}
+
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainStatsRecordPtr, 
virDomainStatsRecordListFree);
 
 static void
@@ -673,6 +707,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] 
= {
     { "Create", virtDBusDomainCreate },
     { "Destroy", virtDBusDomainDestroy },
     { "DetachDevice", virtDBusDomainDetachDevice },
+    { "GetJobInfo", virtDBusDomainGetJobInfo },
     { "GetStats", virtDBusDomainGetStats },
     { "GetVcpus", virtDBusDomainGetVcpus },
     { "GetXMLDesc", virtDBusDomainGetXMLDesc },
-- 
2.15.0

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

Reply via email to