[libvirt] [dbus PATCH 01/25] Implement GetControlInfo method for Domain Interface

Katerina Koukiou kkoukiou at redhat.com
Tue Apr 17 12:04:20 UTC 2018


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

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 98e2873..74b0a62 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -76,6 +76,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#virDomainGetControlInfo"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="jobInfo" 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 8a25ae1..5ec7686 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -3,6 +3,22 @@
 
 #include <libvirt/libvirt.h>
 
+VIRT_DBUS_ENUM_DECL(virtDBusDomainControlState)
+VIRT_DBUS_ENUM_IMPL(virtDBusDomainControlState,
+                    VIR_DOMAIN_CONTROL_LAST,
+                    "ok",
+                    "job",
+                    "occupied",
+                    "error")
+
+VIRT_DBUS_ENUM_DECL(virtDBusDomainControlErrorReason)
+VIRT_DBUS_ENUM_IMPL(virtDBusDomainControlErrorReason,
+                    VIR_DOMAIN_CONTROL_ERROR_REASON_LAST,
+                    "none",
+                    "unknown",
+                    "monitor",
+                    "internal")
+
 VIRT_DBUS_ENUM_DECL(virtDBusDomainJob)
 VIRT_DBUS_ENUM_IMPL(virtDBusDomainJob,
                     VIR_DOMAIN_JOB_LAST,
@@ -472,6 +488,43 @@ 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) == -1)
+        return virtDBusUtilSetLastVirtError(error);
+
+    stateStr = virtDBusDomainControlStateTypeToString(controlInfo->state);
+    if (!stateStr)
+        return;
+    errorReasonStr = virtDBusDomainControlErrorReasonTypeToString(controlInfo->details);
+    if (!errorReasonStr)
+        return;
+
+    *outArgs = g_variant_new("((sst))", stateStr,
+                             errorReasonStr, controlInfo->stateTime);
+}
+
 static void
 virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
                          GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1086,6 +1139,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "Destroy", virtDBusDomainDestroy },
     { "DetachDevice", virtDBusDomainDetachDevice },
     { "GetBlkioParameters", virtDBusDomainGetBlkioParameters },
+    { "GetControlInfo", virtDBusDomainGetControlInfo },
     { "GetJobInfo", virtDBusDomainGetJobInfo },
     { "GetMemoryParameters", virtDBusDomainGetMemoryParameters },
     { "GetSchedulerParameters", virtDBusDomainGetSchedulerParameters },
-- 
2.15.0




More information about the libvir-list mailing list