Skip to content

Commit

Permalink
migration: Maybe VM is paused when migration is cancelled
Browse files Browse the repository at this point in the history
If the migration is cancelled when it is in the completion phase,
the migration state is set to MIGRATION_STATUS_CANCELLING.
The VM maybe wait for the 'pause_sem' semaphore in migration_maybe_pause
function, so that VM always is paused.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
  • Loading branch information
Zhimin Feng authored and Juan Quintela committed Feb 13, 2020
1 parent e18e550 commit 8958338
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions migration/migration.c
Expand Up @@ -2797,14 +2797,22 @@ static int migration_maybe_pause(MigrationState *s,
/* This block intentionally left blank */
}

qemu_mutex_unlock_iothread();
migrate_set_state(&s->state, *current_active_state,
MIGRATION_STATUS_PRE_SWITCHOVER);
qemu_sem_wait(&s->pause_sem);
migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
new_state);
*current_active_state = new_state;
qemu_mutex_lock_iothread();
/*
* If the migration is cancelled when it is in the completion phase,
* the migration state is set to MIGRATION_STATUS_CANCELLING.
* So we don't need to wait a semaphore, otherwise we would always
* wait for the 'pause_sem' semaphore.
*/
if (s->state != MIGRATION_STATUS_CANCELLING) {
qemu_mutex_unlock_iothread();
migrate_set_state(&s->state, *current_active_state,
MIGRATION_STATUS_PRE_SWITCHOVER);
qemu_sem_wait(&s->pause_sem);
migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
new_state);
*current_active_state = new_state;
qemu_mutex_lock_iothread();
}

return s->state == new_state ? 0 : -EINVAL;
}
Expand Down

0 comments on commit 8958338

Please sign in to comment.