mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
migration: Fix race of image locking between src and dst
Previously, dst side will immediately try to lock the write byte upon receiving QEMU_VM_EOF, but at src side, bdrv_inactivate_all() is only done after sending it. If the src host is under load, dst may fail to acquire the lock due to racing with the src unlocking it. Fix this by hoisting the bdrv_inactivate_all() operation before QEMU_VM_EOF. N.B. A further improvement could possibly be done to cleanly handover locks between src and dst, so that there is no window where a third QEMU could steal the locks and prevent src and dst from running. N.B. This commit includes a minor improvement to the error handling by using qemu_file_set_error(). Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Fam Zheng <famz@redhat.com> Message-id: 20170616160658.32290-1-famz@redhat.com Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> [PMM: noted qemu_file_set_error() use in commit as suggested by Daniel] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
edf8bc9842
commit
a1fbe750fd
4 changed files with 25 additions and 18 deletions
|
@ -1553,7 +1553,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running)
|
|||
* Cause any non-postcopiable, but iterative devices to
|
||||
* send out their final data.
|
||||
*/
|
||||
qemu_savevm_state_complete_precopy(ms->to_dst_file, true);
|
||||
qemu_savevm_state_complete_precopy(ms->to_dst_file, true, false);
|
||||
|
||||
/*
|
||||
* in Finish migrate and with the io-lock held everything should
|
||||
|
@ -1597,7 +1597,7 @@ static int postcopy_start(MigrationState *ms, bool *old_vm_running)
|
|||
*/
|
||||
qemu_savevm_send_postcopy_listen(fb);
|
||||
|
||||
qemu_savevm_state_complete_precopy(fb, false);
|
||||
qemu_savevm_state_complete_precopy(fb, false, false);
|
||||
qemu_savevm_send_ping(fb, 3);
|
||||
|
||||
qemu_savevm_send_postcopy_run(fb);
|
||||
|
@ -1695,20 +1695,15 @@ static void migration_completion(MigrationState *s, int current_active_state,
|
|||
ret = global_state_store();
|
||||
|
||||
if (!ret) {
|
||||
bool inactivate = !migrate_colo_enabled();
|
||||
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
|
||||
if (ret >= 0) {
|
||||
qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX);
|
||||
qemu_savevm_state_complete_precopy(s->to_dst_file, false);
|
||||
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
|
||||
inactivate);
|
||||
}
|
||||
/*
|
||||
* Don't mark the image with BDRV_O_INACTIVE flag if
|
||||
* we will go into COLO stage later.
|
||||
*/
|
||||
if (ret >= 0 && !migrate_colo_enabled()) {
|
||||
ret = bdrv_inactivate_all();
|
||||
if (ret >= 0) {
|
||||
s->block_inactive = true;
|
||||
}
|
||||
if (inactivate && ret >= 0) {
|
||||
s->block_inactive = true;
|
||||
}
|
||||
}
|
||||
qemu_mutex_unlock_iothread();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue