diff options
author | Laurent Vivier | 2019-11-29 12:51:32 +0100 |
---|---|---|
committer | Juan Quintela | 2020-01-20 09:10:22 +0100 |
commit | ddad81bd28de665475a87693a93e6cf5d6fd8bab (patch) | |
tree | 04609a68c4720c90edba3dcace302f670eb24a1b | |
parent | migration-test: introduce functions to handle string parameters (diff) | |
download | qemu-ddad81bd28de665475a87693a93e6cf5d6fd8bab.tar.gz qemu-ddad81bd28de665475a87693a93e6cf5d6fd8bab.tar.xz qemu-ddad81bd28de665475a87693a93e6cf5d6fd8bab.zip |
runstate: ignore finishmigrate -> prelaunch transition
Commit 1bd71dce4bf2 tries to prevent a finishmigrate -> prelaunch
transition by exiting at the beginning of the main_loop_should_exit()
function if the state is already finishmigrate.
As the finishmigrate state is set in the migration thread it can
happen concurrently to the function. The migration thread and the
function are normally protected by the iothread mutex and thus the
state should no evolve between the start of the function and its end.
Unfortunately during the function life the lock is released by
pause_all_vcpus() just before the point we need to be sure we are
not in finishmigrate state and if the migration thread is waiting
for the lock it will take the opportunity to change the state
to finishmigrate.
The only way to be sure we are not in the finishmigrate state when
we need is to check the state after the pause_all_vcpus() function.
Fixes: 1bd71dce4bf2 ("runstate: ignore exit request in finish migrate state")
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
-rw-r--r-- | vl.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1604,9 +1604,6 @@ static bool main_loop_should_exit(void) RunState r; ShutdownCause request; - if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { - return false; - } if (preconfig_exit_requested) { if (runstate_check(RUN_STATE_PRECONFIG)) { runstate_set(RUN_STATE_PRELAUNCH); @@ -1635,8 +1632,13 @@ static bool main_loop_should_exit(void) pause_all_vcpus(); qemu_system_reset(request); resume_all_vcpus(); + /* + * runstate can change in pause_all_vcpus() + * as iothread mutex is unlocked + */ if (!runstate_check(RUN_STATE_RUNNING) && - !runstate_check(RUN_STATE_INMIGRATE)) { + !runstate_check(RUN_STATE_INMIGRATE) && + !runstate_check(RUN_STATE_FINISH_MIGRATE)) { runstate_set(RUN_STATE_PRELAUNCH); } } |