[dbus PATCH v2 8/9] Implement NodeSuspendForDuration method for Connect Interface

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

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Connect.xml |  8 ++++++++
 src/connect.c                | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index e46d28d..eb4990e 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -206,6 +206,14 @@
       <arg name="params" type="a{sv}" direction="in"/>
       <arg name="flags" type="u" direction="in"/>
     </method>
+    <method name="NodeSuspendForDuration">
+      <annotation name="org.gtk.GDBus.DocString"
+          value="See https://libvirt.org/html/libvirt-libvirt-host.html#virNodeSuspendForDuration
+                 @target argument should be one of 'mem', 'disk' or 'hybrid'."/>
+      <arg name="target" type="s" direction="in"/>
+      <arg name="duration" type="t" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+    </method>
     <signal name="DomainEvent">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
diff --git a/src/connect.c b/src/connect.c
index cea64cb..4035853 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -13,6 +13,13 @@ VIRT_DBUS_ENUM_IMPL(virtDBusConnectCPUCompareResult,
                     "identical",
                     "superset")
 
+VIRT_DBUS_ENUM_DECL(virtDBusConnectNodeSuspendTarget)
+VIRT_DBUS_ENUM_IMPL(virtDBusConnectNodeSuspendTarget,
+                    VIR_NODE_SUSPEND_TARGET_LAST,
+                    "mem",
+                    "disk",
+                    "hybrid")
+
 static gint virtDBusConnectCredType[] = {
     VIR_CRED_AUTHNAME,
     VIR_CRED_ECHOPROMPT,
@@ -1061,6 +1068,40 @@ virtDBusConnectNodeSetMemoryParameters(GVariant *inArgs,
     }
 }
 
+static void
+virtDBusConnectNodeSuspendForDuration(GVariant *inArgs,
+                                      GUnixFDList *inFDs G_GNUC_UNUSED,
+                                      const gchar *objectPath G_GNUC_UNUSED,
+                                      gpointer userData,
+                                      GVariant **outArgs G_GNUC_UNUSED,
+                                      GUnixFDList **outFDs G_GNUC_UNUSED,
+                                      GError **error)
+{
+    virtDBusConnect *connect = userData;
+    const gchar *targetStr;
+    gint target;
+    guint64 duration;
+    guint flags;
+
+    g_variant_get(inArgs, "(&stu)", &targetStr, &duration, &flags);
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    target = virtDBusConnectNodeSuspendTargetTypeFromString(targetStr);
+    if (target < 0) {
+        g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
+                    "Can't get valid virNodeSuspendTarget from string '%s'.",
+                    targetStr);
+        return;
+    }
+
+    if (virNodeSuspendForDuration(connect->connection, target,
+                                  duration, flags) < 0) {
+        virtDBusUtilSetLastVirtError(error);
+    }
+}
+
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
     { "Encrypted", virtDBusConnectGetEncrypted, NULL },
     { "Hostname", virtDBusConnectGetHostname, NULL },
@@ -1099,6 +1140,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats },
     { "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel },
     { "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters },
+    { "NodeSuspendForDuration", virtDBusConnectNodeSuspendForDuration },
     { 0 }
 };
 
-- 
2.15.0

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