colo: Use file lock in primary_vm_do_failover()
Take the file lock since s->to_dst_file and s->rp_state.from_dst_file may be changed in the migration thread. Signed-off-by: Lukas Straub <lukasstraub2@web.de> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/qemu-devel/20260302-colo_unit_test_multifd-v11-19-d653fb3b1d80@web.de Signed-off-by: Fabiano Rosas <farosas@suse.de>
Lukas Straub committed
Mar 2, 2026 at 12:45 UTC
b2cbd3d0f92a3b1ff311129c85ad6188cdfbb671
1 file changed
+7
-5
migration/colo.c
+7
-5
@@ -173,11 +173,13 @@ static void primary_vm_do_failover(void)
173
* The s->rp_state.from_dst_file and s->to_dst_file may use the
174
* same fd, but we still shutdown the fd for twice, it is harmless.
175
*/
176
- if (s->to_dst_file) {
177
- qemu_file_shutdown(s->to_dst_file);
178
- }
179
- if (s->rp_state.from_dst_file) {
180
- qemu_file_shutdown(s->rp_state.from_dst_file);
176
+ WITH_QEMU_LOCK_GUARD(&s->qemu_file_lock) {
177
+ if (s->to_dst_file) {
178
+ qemu_file_shutdown(s->to_dst_file);
179
+ }
180
+ if (s->rp_state.from_dst_file) {
181
+ qemu_file_shutdown(s->rp_state.from_dst_file);
182
+ }
183
}
184
185
old_state = failover_set_state(FAILOVER_STATUS_ACTIVE,