Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
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 a929802..9358040 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -215,6 +215,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#virConnectDomainEven...
diff --git a/src/connect.c b/src/connect.c
index 3b7d8a3..7d7c7c0 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,
@@ -1096,6 +1103,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 },
@@ -1135,6 +1176,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NodeGetMemoryStats", virtDBusConnectNodeGetMemoryStats },
{ "NodeGetSecurityModel", virtDBusConnectNodeGetSecurityModel },
{ "NodeSetMemoryParameters", virtDBusConnectNodeSetMemoryParameters },
+ { "NodeSuspendForDuration", virtDBusConnectNodeSuspendForDuration },
{ 0 }
};
--
2.15.0