@@ -639,6 +639,20 @@ SRST
whether profiling is on or off.
ERST
+ {
+ .name = "system_sleep",
+ .args_type = "",
+ .params = "",
+ .help = "send ACPI sleep event",
+ .cmd = hmp_system_sleep,
+ },
+
+SRST
+``system_sleep``
+ Push the virtual sleep button; if supported the system will enter
+ an ACPI sleep state.
+ERST
+
{
.name = "system_reset",
.args_type = "",
@@ -189,6 +189,11 @@ void hmp_system_reset(Monitor *mon, const QDict *qdict)
qmp_system_reset(NULL);
}
+void hmp_system_sleep(Monitor *mon, const QDict *qdict)
+{
+ qmp_system_sleep(NULL);
+}
+
void hmp_system_powerdown(Monitor *mon, const QDict *qdict)
{
qmp_system_powerdown(NULL);
@@ -276,6 +276,15 @@ void qmp_system_reset(Error **errp)
qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET);
}
+void qmp_system_sleep(Error **errp)
+{
+ if (!qemu_wakeup_suspend_enabled()) {
+ error_setg(errp,
+ "suspend from running is not supported by this guest");
+ return;
+ }
+}
+
void qmp_system_powerdown(Error **errp)
{
qemu_system_powerdown_request();
@@ -43,6 +43,7 @@ void hmp_quit(Monitor *mon, const QDict *qdict);
void hmp_stop(Monitor *mon, const QDict *qdict);
void hmp_sync_profile(Monitor *mon, const QDict *qdict);
void hmp_system_reset(Monitor *mon, const QDict *qdict);
+void hmp_system_sleep(Monitor *mon, const QDict *qdict);
void hmp_system_powerdown(Monitor *mon, const QDict *qdict);
void hmp_exit_preconfig(Monitor *mon, const QDict *qdict);
void hmp_announce_self(Monitor *mon, const QDict *qdict);
@@ -362,6 +362,24 @@
##
{ 'command': 'system_reset' }
+##
+# @system_sleep:
+#
+# Requests that a guest perform a ACPI sleep transition by pushing a virtual
+# sleep button.
+#
+# .. note:: A guest may or may not respond to this command. This command
+# returning does not indicate that a guest has accepted the request
+# or that it has gone to sleep.
+#
+# .. qmp-example::
+#
+# -> { "execute": "system_sleep" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'system_sleep' }
+
##
# @system_powerdown:
#
@@ -23,6 +23,7 @@
'set_password',
'system_powerdown',
'system_reset',
+ 'system_sleep',
'system_wakeup' ],
# Commands allowed to return a non-dictionary
'command-returns-exceptions': [
Followng hmp/qmp commands are implemented for pressing virtual sleep button, hmp: system_sleep qmp: { "execute": "system_sleep" } These commands put the guest into suspend or other power states depending on the power settings inside the guest. Signed-off-by: Annie Li <annie.li@oracle.com> --- hmp-commands.hx | 14 ++++++++++++++ hw/core/machine-hmp-cmds.c | 5 +++++ hw/core/machine-qmp-cmds.c | 9 +++++++++ include/monitor/hmp.h | 1 + qapi/machine.json | 18 ++++++++++++++++++ qapi/pragma.json | 1 + 6 files changed, 48 insertions(+)