[PATCH] runstate: do not force prelaunch on reset during save-vm

Erik Fastermann posted 1 patch 1 week, 3 days ago
system/runstate.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] runstate: do not force prelaunch on reset during save-vm
Posted by Erik Fastermann 1 week, 3 days ago
A reset processed while the VM sits in 'save-vm' aborts QEMU:

    invalid runstate transition: 'save-vm' -> 'prelaunch'

The window is reachable over QMP. dump-guest-memory with detach=true
stops the VM with vm_stop(RUN_STATE_SAVE_VM) in dump_init() and then
returns once dump_thread has been spawned, so the main loop keeps
running with the VM in 'save-vm' for the whole duration of the dump.
A system_reset in that window kills the guest, as
main_loop_should_exit() forces the run state to 'prelaunch'.

'save-vm' needs the same treatment as 'finish-migrate' in commit
1bd71dce4b ("runstate: ignore exit request in finish migrate state").
The reset cannot be applied to a run state whose only exits are back to
'running' or 'suspended', so leave it alone: dump_cleanup() ends it
with vm_start() once the dump thread is done.

Signed-off-by: Erik Fastermann <e.fastermann@proxmox.com>
---
 system/runstate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/system/runstate.c b/system/runstate.c
index d3e64d2b62..1d65a4d444 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -1075,7 +1075,8 @@ static bool main_loop_should_exit(int *status)
          */
         if (!runstate_check(RUN_STATE_RUNNING) &&
                 !runstate_check(RUN_STATE_INMIGRATE) &&
-                !runstate_check(RUN_STATE_FINISH_MIGRATE)) {
+                !runstate_check(RUN_STATE_FINISH_MIGRATE) &&
+                !runstate_check(RUN_STATE_SAVE_VM)) {
             runstate_set(RUN_STATE_PRELAUNCH);
         }
     }
-- 
2.47.3