diff options
author | Zhanghaoyu (A) <haoyu.zhang@huawei.com> | 2013-11-07 08:21:23 +0000 |
---|---|---|
committer | Juan Quintela <quintela@redhat.com> | 2014-01-13 12:39:48 +0100 |
commit | 6f2b811a61810a7fd9f9a5085de223f66b823342 (patch) | |
tree | 82d11cbf7c1010ebca60364ff92afe118e9e961e | |
parent | dd089c0a1e928fb80ba8a37983c1b0e9232d1c8b (diff) |
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: Zeng Junliang <zengjunliang@huawei.com>
Signed-off-by: Zhang Haoyu <haoyu.zhang@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
-rw-r--r-- | migration.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/migration.c b/migration.c index 2b1ab20c54..fd73b97bd6 100644 --- a/migration.c +++ b/migration.c @@ -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) |