Hi Erik,

On 16/9/26 12:12, Erik Fastermann wrote:
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'.

Since this is in rebuild_guest() path, Cc'ing Ani in case the dump
thread could read an unmapped or stale block list on confidential
guest.

'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',

The reset is applied; only the runstate is kept at SAVE_VM.

so leave it alone: dump_cleanup() ends it
with vm_start() once the dump thread is done.

I haven't checked in which state are devices during a detached dump,
pre- or post-reset, do you happent to know? (could the reset be
deferred / rejected in that case?)

The abort fix is reasonable but could you add a qtest?

Signed-off-by: Erik Fastermann <[email protected]>
---
  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)) {

Side note, it seems we reached the usefulness of runstate_check()
calls here; adding another local helper would help readability.

              runstate_set(RUN_STATE_PRELAUNCH);
          }
      }


Reply via email to