summaryrefslogtreecommitdiff
path: root/qga
diff options
context:
space:
mode:
authorMichael Roth <mdroth@linux.vnet.ibm.com>2012-03-12 12:50:02 -0500
committerMichael Roth <mdroth@linux.vnet.ibm.com>2012-03-12 15:09:18 -0500
commitf54603b6aa765514b2519e74114a2f417759d727 (patch)
treec74ce9bc3f1996510da203bc8ff16b98a0091471 /qga
parentaa59637ea1c6a4c83430933f9c44c43e6c3f1b69 (diff)
downloadqemu-f54603b6aa765514b2519e74114a2f417759d727.tar.gz
qemu-f54603b6aa765514b2519e74114a2f417759d727.tar.bz2
qemu-f54603b6aa765514b2519e74114a2f417759d727.zip
qemu-ga: add win32 guest-suspend-ram command
S3 sleep implementation for windows.
Diffstat (limited to 'qga')
-rw-r--r--qga/commands-win32.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 062e519054..b7600ed89a 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)