diff --git a/migration/colo.c b/migration/colo.c index ce02c71d88..dc47d03874 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -173,11 +173,13 @@ static void primary_vm_do_failover(void) * The s->rp_state.from_dst_file and s->to_dst_file may use the * same fd, but we still shutdown the fd for twice, it is harmless. */ - if (s->to_dst_file) { - qemu_file_shutdown(s->to_dst_file); - } - if (s->rp_state.from_dst_file) { - qemu_file_shutdown(s->rp_state.from_dst_file); + WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) { + if (s->to_dst_file) { + qemu_file_shutdown(s->to_dst_file); + } + if (s->rp_state.from_dst_file) { + qemu_file_shutdown(s->rp_state.from_dst_file); + } } old_state = failover_set_state(FAILOVER_STATUS_ACTIVE,