Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Domain.xml | 6 +++++
src/domain.c | 62 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index e11b0b7..cb4da18 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -164,6 +164,12 @@
<arg name="flags" type="u" direction="in"/>
<arg name="BlkioParameters" type="a{sv}"
direction="out"/>
</method>
+ <method name="GetControlInfo">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetControlI...
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="controlInfo" type="(sst)"
direction="out"/>
+ </method>
<method name="GetJobInfo">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo&...
diff --git a/src/domain.c b/src/domain.c
index bcec3e6..f4d8f7e 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -3,6 +3,22 @@
#include <libvirt/libvirt.h>
+VIRT_DBUS_ENUM_DECL(virtDBusDomainControlErrorReason)
+VIRT_DBUS_ENUM_IMPL(virtDBusDomainControlErrorReason,
+ VIR_DOMAIN_CONTROL_ERROR_REASON_LAST,
+ "none",
+ "unknown",
+ "monitor",
+ "internal")
+
+VIRT_DBUS_ENUM_DECL(virtDBusDomainControlState)
+VIRT_DBUS_ENUM_IMPL(virtDBusDomainControlState,
+ VIR_DOMAIN_CONTROL_LAST,
+ "ok",
+ "job",
+ "occupied",
+ "error")
+
VIRT_DBUS_ENUM_DECL(virtDBusDomainJob)
VIRT_DBUS_ENUM_IMPL(virtDBusDomainJob,
VIR_DOMAIN_JOB_LAST,
@@ -819,6 +835,51 @@ virtDBusDomainGetBlkioParameters(GVariant *inArgs,
*outArgs = g_variant_new_tuple(&grecords, 1);
}
+static void
+virtDBusDomainGetControlInfo(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_autofree virDomainControlInfoPtr controlInfo = NULL;
+ const gchar *stateStr;
+ const gchar *errorReasonStr;
+ guint flags;
+
+ g_variant_get(inArgs, "(u)", &flags);
+
+ domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+ if (!domain)
+ return;
+
+ controlInfo = g_new0(virDomainControlInfo, 1);
+ if (virDomainGetControlInfo(domain, controlInfo, flags) < 0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ stateStr = virtDBusDomainControlStateTypeToString(controlInfo->state);
+ if (!stateStr) {
+ g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
+ "Can't format virDomainControlState '%d' to
string.",
+ controlInfo->state);
+ return;
+ }
+ errorReasonStr =
virtDBusDomainControlErrorReasonTypeToString(controlInfo->details);
+ if (!errorReasonStr) {
+ g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
+ "Can't format virDomainControlErrorReason '%d' to
string.",
+ controlInfo->details);
+ return;
+ }
+
+ *outArgs = g_variant_new("((sst))", stateStr,
+ errorReasonStr, controlInfo->stateTime);
+}
+
static void
virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1666,6 +1727,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
{ "FSThaw", virtDBusDomainFSThaw },
{ "FSTrim", virtDBusDomainFSTrim },
{ "GetBlkioParameters", virtDBusDomainGetBlkioParameters },
+ { "GetControlInfo", virtDBusDomainGetControlInfo },
{ "GetJobInfo", virtDBusDomainGetJobInfo },
{ "GetMemoryParameters", virtDBusDomainGetMemoryParameters },
{ "GetSchedulerParameters", virtDBusDomainGetSchedulerParameters },
--
2.15.0