[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 07/30] runstate: ignore finishmigrate -> prelaunch transition
From: |
Juan Quintela |
Subject: |
[PULL 07/30] runstate: ignore finishmigrate -> prelaunch transition |
Date: |
Tue, 14 Jan 2020 13:52:31 +0100 |
From: Laurent Vivier <address@hidden>
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 <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
vl.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/vl.c b/vl.c
index 158a05ed32..ba3e176094 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
}
}
--
2.24.1
- [PULL 00/30] Migration pull patches (take 4), Juan Quintela, 2020/01/14
- [PULL 01/30] multifd: Initialize local variable, Juan Quintela, 2020/01/14
- [PULL 02/30] multifd: Allocate uint64_t instead of ram_addr_t, Juan Quintela, 2020/01/14
- [PULL 03/30] migration-test: Add migration multifd test, Juan Quintela, 2020/01/14
- [PULL 04/30] migration: Make sure that we don't call write() in case of error, Juan Quintela, 2020/01/14
- [PULL 05/30] migration-test: introduce functions to handle string parameters, Juan Quintela, 2020/01/14
- [PULL 06/30] migration-test: ppc64: fix FORTH test program, Juan Quintela, 2020/01/14
- [PULL 07/30] runstate: ignore finishmigrate -> prelaunch transition,
Juan Quintela <=
- [PULL 08/30] ram.c: remove unneeded labels, Juan Quintela, 2020/01/14
- [PULL 09/30] migration: Rate limit inside host pages, Juan Quintela, 2020/01/14
- [PULL 10/30] migration: Fix incorrect integer->float conversion caught by clang, Juan Quintela, 2020/01/14
- [PULL 11/30] migration: Fix the re-run check of the migrate-incoming command, Juan Quintela, 2020/01/14
- [PULL 12/30] misc: use QEMU_IS_ALIGNED, Juan Quintela, 2020/01/14
- [PULL 13/30] migration: add savevm_state_handler_remove(), Juan Quintela, 2020/01/14
- [PULL 14/30] migration: savevm_state_handler_insert: constant-time element insertion, Juan Quintela, 2020/01/14
- [PULL 15/30] migration/ram: Yield periodically to the main loop, Juan Quintela, 2020/01/14
- [PULL 16/30] migration/postcopy: reduce memset when it is zero page and matches_target_page_size, Juan Quintela, 2020/01/14
- [PULL 17/30] migration/postcopy: wait for decompress thread in precopy, Juan Quintela, 2020/01/14