Patchwork [2/3] qemu-ga: add guest-suspend-ram

login
register
mail settings
Submitter Luiz Capitulino
Date Feb. 28, 2012, 2:03 p.m.
Message ID <1330437785-15912-3-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/143469/
State New
Headers show

Comments

Luiz Capitulino - Feb. 28, 2012, 2:03 p.m.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qapi-schema-guest.json |   28 ++++++++++++++++++++++++++++
 qga/commands-posix.c   |   10 ++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

Patch

diff --git a/qapi-schema-guest.json b/qapi-schema-guest.json
index f4e0e1d..b102311 100644
--- a/qapi-schema-guest.json
+++ b/qapi-schema-guest.json
@@ -319,3 +319,31 @@ 
 # Since: 1.1
 ##
 { 'command': 'guest-suspend-disk' }
+
+##
+# @guest-suspend-ram
+#
+# Suspend guest to ram.
+#
+# This command tries to execute the scripts provided by the pm-utils package.
+# If it's not available, the suspend operation will be performed by manually
+# writing to a sysfs file.
+#
+# For the best results it's strongly recommended to have the pm-utils
+# package installed in the guest.
+#
+# IMPORTANT: guest-suspend-ram requires QEMU to support the 'system_wakeup'
+# command.  Thus, it's *required* to query QEMU for the presence of the
+# 'system_wakeup' command before issuing guest-suspend-ram.
+#
+# Returns: nothing on success
+#          If suspend to ram is not supported, Unsupported
+#
+# Notes: o This is an asynchronous request. There's no guarantee a response
+#          will be sent
+#        o It's strongly recommended to issue the guest-sync command before
+#          sending commands when the guest resumes
+#
+# Since: 1.1
+##
+{ 'command': 'guest-suspend-ram' }
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index af785f5..134c130 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -705,6 +705,16 @@  void qmp_guest_suspend_disk(Error **err)
     guest_suspend("pm-hibernate", "disk", err);
 }
 
+void qmp_guest_suspend_ram(Error **err)
+{
+    bios_supports_mode("pm-is-supported", "--suspend", "mem", err);
+    if (error_is_set(err)) {
+        return;
+    }
+
+    guest_suspend("pm-suspend", "mem", err);
+}
+
 /* register init/cleanup routines for stateful command groups */
 void ga_command_state_init(GAState *s, GACommandState *cs)
 {