Commit 6f2b811a authored by Zhanghaoyu (A)'s avatar Zhanghaoyu (A) Committed by Juan Quintela

avoid a bogus COMPLETED->CANCELLED transition

Avoid a bogus COMPLETED->CANCELLED transition.
There is a period of time from the timing of setting COMPLETED state to that of migration thread exits, so during which it's problematic in COMPLETED->CANCELLED transition.
Signed-off-by: default avatarZeng Junliang <zengjunliang@huawei.com>
Signed-off-by: default avatarZhang Haoyu <haoyu.zhang@huawei.com>
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
parent dd089c0a
......@@ -326,9 +326,16 @@ void migrate_fd_error(MigrationState *s)
static void migrate_fd_cancel(MigrationState *s)
{
int old_state ;
DPRINTF("cancelling migration\n");
migrate_set_state(s, s->state, MIG_STATE_CANCELLED);
do {
old_state = s->state;
if (old_state != MIG_STATE_SETUP && old_state != MIG_STATE_ACTIVE) {
break;
}
migrate_set_state(s, old_state, MIG_STATE_CANCELLED);
} while (s->state != MIG_STATE_CANCELLED);
}
void add_migration_state_change_notifier(Notifier *notify)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment