[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/21] migration/postcopy: check PostcopyState before setting to P
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 16/21] migration/postcopy: check PostcopyState before setting to POSTCOPY_INCOMING_RUNNING |
Date: |
Fri, 11 Oct 2019 20:16:41 +0100 |
From: Wei Yang <address@hidden>
Currently, we set PostcopyState blindly to RUNNING, even we found the
previous state is not LISTENING. This will lead to a corner case.
First let's look at the code flow:
qemu_loadvm_state_main()
ret = loadvm_process_command()
loadvm_postcopy_handle_run()
return -1;
if (ret < 0) {
if (postcopy_state_get() == POSTCOPY_INCOMING_RUNNING)
...
}
>From above snippet, the corner case is loadvm_postcopy_handle_run()
always sets state to RUNNING. And then it checks the previous state. If
the previous state is not LISTENING, it will return -1. But at this
moment, PostcopyState is already been set to RUNNING.
Then ret is checked in qemu_loadvm_state_main(), when it is -1
PostcopyState is checked. Current logic would pause postcopy and retry
if PostcopyState is RUNNING. This is not what we expect, because
postcopy is not active yet.
This patch makes sure state is set to RUNNING only previous state is
LISTENING by checking the state first.
Signed-off-by: Wei Yang <address@hidden>
Suggested by: Peter Xu <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Peter Xu <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
migration/savevm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/migration/savevm.c b/migration/savevm.c
index 95574c4e9d..8d95e261f6 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1933,7 +1933,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaque)
/* After all discards we can start running and asking for pages */
static int loadvm_postcopy_handle_run(MigrationIncomingState *mis)
{
- PostcopyState ps = postcopy_state_set(POSTCOPY_INCOMING_RUNNING);
+ PostcopyState ps = postcopy_state_get();
trace_loadvm_postcopy_handle_run();
if (ps != POSTCOPY_INCOMING_LISTENING) {
@@ -1941,6 +1941,7 @@ static int
loadvm_postcopy_handle_run(MigrationIncomingState *mis)
return -1;
}
+ postcopy_state_set(POSTCOPY_INCOMING_RUNNING);
mis->bh = qemu_bh_new(loadvm_postcopy_handle_run_bh, mis);
qemu_bh_schedule(mis->bh);
--
2.23.0
- [PULL 04/21] migration: Use automatic rcu_read unlock in ram.c, (continued)
- [PULL 04/21] migration: Use automatic rcu_read unlock in ram.c, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 06/21] rcu: Use automatic rc_read unlock in core memory/exec code, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 09/21] migration/postcopy: map large zero page in postcopy_ram_incoming_setup(), Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 07/21] migration: Don't try and recover return path in non-postcopy, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 11/21] migration: pass in_postcopy instead of check state again, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 10/21] migration/postcopy: fix typo in mark_postcopy_blocktime_begin's comment, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 12/21] migration: report SaveStateEntry id and name on failure, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 13/21] migration/postcopy: mis->have_listen_thread check will never be touched, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 14/21] migration/postcopy: postpone setting PostcopyState to END, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 15/21] migration/postcopy: rename postcopy_ram_enable_notify to postcopy_ram_incoming_setup, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 16/21] migration/postcopy: check PostcopyState before setting to POSTCOPY_INCOMING_RUNNING,
Dr. David Alan Gilbert (git) <=
- [PULL 17/21] migration/multifd: fix a typo in comment of multifd_recv_unfill_packet(), Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 18/21] migration/multifd: use pages->allocated instead of the static max, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 19/21] migration/multifd: initialize packet->magic/version once at setup stage, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 20/21] migration/multifd: pages->used would be cleared when attach to multifd_send_state, Dr. David Alan Gilbert (git), 2019/10/11
- [PULL 21/21] migration: Support gtree migration, Dr. David Alan Gilbert (git), 2019/10/11
- Re: [PULL 00/21] migration queue, Peter Maydell, 2019/10/14