@samitouri / QOSamiQemu / commits / 37c74b1dbb

multifd: Fix hang if send thread errors during sync

When a send thread encounters an error (as is the case with yank), it sets multifd_send_state->exiting and the other threads exit too. This races with multifd_send_sync_main() which now hangs at qemu_sem_wait(&p->sem_sync) in multifd_send_sync_main() line 647 as it waits for threads that have exited. Fix this by kicking the semaphores when exiting the send threads. I encountered this hang when stress testing the colo unit test, though I was unable to write a migration test to reliably hit this. Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Lukas Straub <lukasstraub2@web.de> Link: https://lore.kernel.org/qemu-devel/20260302-colo_unit_test_multifd-v11-18-d653fb3b1d80@web.de Signed-off-by: Fabiano Rosas <farosas@suse.de>

Lukas Straub committed Mar 2, 2026 at 12:45 UTC 37c74b1dbb205506dc17cfc9cb3ba3ae7e207986
1 file changed +6 -1
migration/multifd.c
+6 -1
@@ -772,9 +772,14 @@ out:
772 assert(local_err);
773 trace_multifd_send_error(p->id);
774 multifd_send_error_propagate(local_err);
775 - multifd_send_kick_main(p);
775 }
776
777 + /*
778 + * Always kick the main thread: The main thread might wait on this thread
779 + * while another thread encounters an error and signals this thread to exit.
780 + */
781 + multifd_send_kick_main(p);
782 +
783 rcu_unregister_thread();
784 trace_multifd_send_thread_end(p->id, p->packets_sent);
785