[libvirt] [dbus PATCH v2 11/22] Implement MigrateGetMaxDowntime method for Domain Interface

Katerina Koukiou posted 22 patches 7 years, 1 month ago
There is a newer version of this series
[libvirt] [dbus PATCH v2 11/22] Implement MigrateGetMaxDowntime method for Domain Interface
Posted by Katerina Koukiou 7 years, 1 month ago
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
---
 data/org.libvirt.Domain.xml |  6 ++++++
 src/domain.c                | 31 +++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index c509b4e..3903689 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -97,6 +97,12 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="stats" type="a{st}" direction="out"/>
     </method>
+    <method name="MigrateGetMaxDowntime">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateGetMaxDowntime"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="downtime" type="t" direction="out"/>
+    </method>
     <method name="MigrateSetMaxDowntime">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMigrateSetMaxDowntime"/>
diff --git a/src/domain.c b/src/domain.c
index c42e1c6..e1b2d72 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -575,6 +575,36 @@ virtDBusDomainMemoryStats(GVariant *inArgs,
     *outArgs = g_variant_new_tuple(&gstats, 1);
 }
 
+static void
+virtDBusDomainMigrateGetMaxDowntime(GVariant *inArgs,
+                                    GUnixFDList *inFDs G_GNUC_UNUSED,
+                                    const gchar *objectPath,
+                                    gpointer userData,
+                                    GVariant **outArgs G_GNUC_UNUSED,
+                                    GUnixFDList **outFDs G_GNUC_UNUSED,
+                                    GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virDomain) domain = NULL;
+    guint64 downtime;
+    guint flags;
+    gint ret;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    ret = virDomainMigrateGetMaxDowntime(domain,
+                                         (long long unsigned int *)&downtime,
+                                         flags);
+    if (ret < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *outArgs = g_variant_new("(t)", downtime);
+}
+
 static void
 virtDBusDomainMigrateSetMaxDowntime(GVariant *inArgs,
                                     GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -757,6 +787,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "GetVcpus", virtDBusDomainGetVcpus },
     { "GetXMLDesc", virtDBusDomainGetXMLDesc },
     { "MemoryStats", virtDBusDomainMemoryStats },
+    { "MigrateGetMaxDowntime", virtDBusDomainMigrateGetMaxDowntime },
     { "MigrateSetMaxDowntime", virtDBusDomainMigrateSetMaxDowntime },
     { "Reboot", virtDBusDomainReboot },
     { "Reset", virtDBusDomainReset },
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH v2 11/22] Implement MigrateGetMaxDowntime method for Domain Interface
Posted by Pavel Hrdina 7 years, 1 month ago
On Thu, Apr 12, 2018 at 04:32:50PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
> ---
>  data/org.libvirt.Domain.xml |  6 ++++++
>  src/domain.c                | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 37 insertions(+)

[...]

> +static void
> +virtDBusDomainMigrateGetMaxDowntime(GVariant *inArgs,
> +                                    GUnixFDList *inFDs G_GNUC_UNUSED,
> +                                    const gchar *objectPath,
> +                                    gpointer userData,
> +                                    GVariant **outArgs G_GNUC_UNUSED,

outArgs is used so remove G_GNUC_UNUSED

> +                                    GUnixFDList **outFDs G_GNUC_UNUSED,
> +                                    GError **error)
> +{
> +    virtDBusConnect *connect = userData;
> +    g_autoptr(virDomain) domain = NULL;
> +    guint64 downtime;

For consistency this could be gulong and also in the previous patch.
Both are 'unsigned long'.

> +    guint flags;
> +    gint ret;
> +
> +    g_variant_get(inArgs, "(u)", &flags);
> +
> +    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
> +    if (!domain)
> +        return;
> +
> +    ret = virDomainMigrateGetMaxDowntime(domain,
> +                                         (long long unsigned int *)&downtime,

The 'int' is redundant, you can remove it, and usually we put the
'unsigned' keyword as first one.

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