qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: ghammer@redhat.com, mprivozn@redhat.com, aliguori@us.ibm.com,
	lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH 5/7] qemu-ga: add win32 guest-suspend-ram command
Date: Mon, 12 Mar 2012 15:16:44 -0500	[thread overview]
Message-ID: <1331583406-12873-6-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1331583406-12873-1-git-send-email-mdroth@linux.vnet.ibm.com>

S3 sleep implementation for windows.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qga/commands-win32.c |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 062e519..b7600ed 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -174,7 +174,8 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err)
 }
 
 typedef enum {
-    GUEST_SUSPEND_MODE_DISK
+    GUEST_SUSPEND_MODE_DISK,
+    GUEST_SUSPEND_MODE_RAM
 } GuestSuspendMode;
 
 static void check_suspend_mode(GuestSuspendMode mode, Error **err)
@@ -192,18 +193,24 @@ static void check_suspend_mode(GuestSuspendMode mode, Error **err)
         goto out;
     }
 
-    if (mode == GUEST_SUSPEND_MODE_DISK) {
-        if (sys_pwr_caps.SystemS4) {
-            return;
+    switch (mode) {
+    case GUEST_SUSPEND_MODE_DISK:
+        if (!sys_pwr_caps.SystemS4) {
+            error_set(&local_err, QERR_QGA_COMMAND_FAILED,
+                      "suspend-to-disk not supported by OS");
         }
-    } else {
+        break;
+    case GUEST_SUSPEND_MODE_RAM:
+        if (!sys_pwr_caps.SystemS3) {
+            error_set(&local_err, QERR_QGA_COMMAND_FAILED,
+                      "suspend-to-ram not supported by OS");
+        }
+        break;
+    default:
         error_set(&local_err, QERR_INVALID_PARAMETER_VALUE, "mode",
                   "GuestSuspendMode");
-        goto out;
     }
 
-    error_set(&local_err, QERR_QGA_COMMAND_FAILED,
-              "suspend mode not supported by OS");
 out:
     if (local_err) {
         error_propagate(err, local_err);
@@ -239,7 +246,16 @@ void qmp_guest_suspend_disk(Error **err)
 
 void qmp_guest_suspend_ram(Error **err)
 {
-    error_set(err, QERR_UNSUPPORTED);
+    GuestSuspendMode *mode = g_malloc(sizeof(GuestSuspendMode));
+
+    *mode = GUEST_SUSPEND_MODE_RAM;
+    check_suspend_mode(*mode, err);
+    acquire_privilege(SE_SHUTDOWN_NAME, err);
+    execute_async(do_suspend, mode, err);
+
+    if (error_is_set(err)) {
+        g_free(mode);
+    }
 }
 
 void qmp_guest_suspend_hybrid(Error **err)
-- 
1.7.4.1

  parent reply	other threads:[~2012-03-12 20:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-12 20:16 [Qemu-devel] [PULL] qemu-ga patch queue Michael Roth
2012-03-12 20:16 ` [Qemu-devel] [PATCH 1/7] qemu-ga: add guest-suspend-disk Michael Roth
2012-03-12 20:16 ` [Qemu-devel] [PATCH 2/7] qemu-ga: add guest-suspend-ram Michael Roth
2012-03-12 20:16 ` [Qemu-devel] [PATCH 3/7] qemu-ga: add guest-suspend-hybrid Michael Roth
2012-03-12 20:16 ` [Qemu-devel] [PATCH 4/7] qemu-ga: add win32 guest-suspend-disk command Michael Roth
2012-03-12 20:16 ` Michael Roth [this message]
2012-03-12 20:16 ` [Qemu-devel] [PATCH 6/7] qemu-ga: add guest-network-get-interfaces command Michael Roth
2012-03-12 20:16 ` [Qemu-devel] [PATCH 7/7] qemu-ga: add guest-sync-delimited Michael Roth
2012-03-13  2:22 ` [Qemu-devel] [PULL] qemu-ga patch queue Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331583406-12873-6-git-send-email-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=ghammer@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mprivozn@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).