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

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

 



On Tue, Apr 17, 2018 at 02:04:20PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
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"/>

s/jobInfo/controlInfo/

+    </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")
+

Any plans to keep these alphabetically sorted?

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)

s/== -1/< 0/

+        return virtDBusUtilSetLastVirtError(error);
+
+    stateStr = virtDBusDomainControlStateTypeToString(controlInfo->state);
+    if (!stateStr)
+        return;
+    errorReasonStr = virtDBusDomainControlErrorReasonTypeToString(controlInfo->details);
+    if (!errorReasonStr)
+        return;

Two returns without an error reported. Is that the policy?
virtDBusDomainGetJobInfo does report an error when it fails to convert an enum.

Jano

+
+    *outArgs = g_variant_new("((sst))", stateStr,
+                             errorReasonStr, controlInfo->stateTime);
+}
+
static void
virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
                         GUnixFDList *inFDs G_GNUC_UNUSED,

Attachment: signature.asc
Description: Digital signature

--
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