From: Steve Sistare Date: Wed, 3 Jan 2024 20:05:30 +0000 (-0800) Subject: cpus: vm_was_suspended X-Git-Tag: v9.0.0-rc0~124^2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f06f316d3e7f100cbbeaf0ea001d6332c12e7ab5;p=thirdparty%2Fqemu.git cpus: vm_was_suspended Add a state variable to remember if a vm previously transitioned into a suspended state. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/1704312341-66640-2-git-send-email-steven.sistare@oracle.com Signed-off-by: Peter Xu --- diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index c8c2bd8a61b..88a67e22b0c 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -51,6 +51,8 @@ int vm_prepare_start(bool step_pending); int vm_stop(RunState state); int vm_stop_force_state(RunState state); int vm_shutdown(void); +void vm_set_suspended(bool suspended); +bool vm_get_suspended(void); typedef enum WakeupReason { /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */ diff --git a/system/cpus.c b/system/cpus.c index a444a747f01..9f631ab734c 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -259,6 +259,21 @@ void cpu_interrupt(CPUState *cpu, int mask) } } +/* + * True if the vm was previously suspended, and has not been woken or reset. + */ +static int vm_was_suspended; + +void vm_set_suspended(bool suspended) +{ + vm_was_suspended = suspended; +} + +bool vm_get_suspended(void) +{ + return vm_was_suspended; +} + static int do_vm_stop(RunState state, bool send_stop) { int ret = 0;