Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Domain.xml | 7 +++++++
src/domain.c | 47 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 6f80cc7..c640bcb 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -178,6 +178,13 @@
<arg name="flags" type="u" direction="in"/>
<arg name="blockIoTune" type="a{sv}"
direction="out"/>
</method>
+ <method name="GetBlockJobInfo">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetBlockJob...
+ <arg name="disk" type="s" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="blockJobInfo" type="(sttt)"
direction="out"/>
+ </method>
<method name="GetControlInfo">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetControlI...
diff --git a/src/domain.c b/src/domain.c
index b4bdd34..75d29c4 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -3,6 +3,15 @@
#include <libvirt/libvirt.h>
+VIRT_DBUS_ENUM_DECL(virtDBusDomainBlockJob)
+VIRT_DBUS_ENUM_IMPL(virtDBusDomainBlockJob,
+ VIR_DOMAIN_BLOCK_JOB_TYPE_LAST,
+ "unknown",
+ "pull",
+ "copy",
+ "commit",
+ "active-commit")
+
VIRT_DBUS_ENUM_DECL(virtDBusDomainControlErrorReason)
VIRT_DBUS_ENUM_IMPL(virtDBusDomainControlErrorReason,
VIR_DOMAIN_CONTROL_ERROR_REASON_LAST,
@@ -905,6 +914,43 @@ virtDBusDomainGetBlockIoTune(GVariant *inArgs,
*outArgs = g_variant_new_tuple(&grecords, 1);
}
+static void
+virtDBusDomainGetBlockJobInfo(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;
+ virDomainBlockJobInfo info;
+ const gchar *disk;
+ guint flags;
+ const gchar *blockJobTypeStr;
+
+ g_variant_get(inArgs, "(&su)", &disk, &flags);
+
+ domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+ if (!domain)
+ return;
+
+ if (virDomainGetBlockJobInfo(domain, disk, &info, flags) < 0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ blockJobTypeStr = virtDBusDomainBlockJobTypeToString(info.type);
+ if (!blockJobTypeStr) {
+ g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
+ "Can't format virDomainBlockJobType '%d' to
string.",
+ info.type);
+ return;
+ }
+
+ *outArgs = g_variant_new("((sttt))", blockJobTypeStr, info.bandwidth,
+ info.cur, info.end);
+}
+
static void
virtDBusDomainGetControlInfo(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -2026,6 +2072,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
{ "FSTrim", virtDBusDomainFSTrim },
{ "GetBlkioParameters", virtDBusDomainGetBlkioParameters },
{ "GetBlockIoTune", virtDBusDomainGetBlockIoTune },
+ { "GetBlockJobInfo", virtDBusDomainGetBlockJobInfo },
{ "GetControlInfo", virtDBusDomainGetControlInfo },
{ "GetJobInfo", virtDBusDomainGetJobInfo },
{ "GetMemoryParameters", virtDBusDomainGetMemoryParameters },
--
2.15.0