mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
migration: Fail migration on bdrv_flush_all() error
If bdrv_flush_all() returns an error, there is an inconsistency in the view of an image file between the source and the destination host. Completing the migration would lead to corruption. Better abort migration in this case. To reproduce this case, try the following (ensures that there is something to flush, and then fails that flush): $ qemu-img create -f qcow2 test.qcow2 1G $ cat blkdebug.cfg [inject-error] event = "flush_to_os" errno = "5" $ qemu-system-x86_64 -hda blkdebug:blkdebug.cfg:test.qcow2 -monitor stdio (qemu) qemu-io ide0-hd0 "write 0 4k" (qemu) migrate ... Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
5698346391
commit
0e1146a7a0
1 changed files with 14 additions and 3 deletions
17
migration.c
17
migration.c
|
@ -527,15 +527,26 @@ static void *migration_thread(void *opaque)
|
|||
if (pending_size && pending_size >= max_size) {
|
||||
qemu_savevm_state_iterate(s->file);
|
||||
} else {
|
||||
int ret;
|
||||
|
||||
DPRINTF("done iterating\n");
|
||||
qemu_mutex_lock_iothread();
|
||||
start_time = qemu_get_clock_ms(rt_clock);
|
||||
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
|
||||
old_vm_running = runstate_is_running();
|
||||
vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
|
||||
qemu_file_set_rate_limit(s->file, INT_MAX);
|
||||
qemu_savevm_state_complete(s->file);
|
||||
|
||||
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
|
||||
if (ret >= 0) {
|
||||
qemu_file_set_rate_limit(s->file, INT_MAX);
|
||||
qemu_savevm_state_complete(s->file);
|
||||
}
|
||||
qemu_mutex_unlock_iothread();
|
||||
|
||||
if (ret < 0) {
|
||||
migrate_finish_set_state(s, MIG_STATE_ERROR);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!qemu_file_get_error(s->file)) {
|
||||
migrate_finish_set_state(s, MIG_STATE_COMPLETED);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue