migration: Join the return path thread before releasing to_dst_file
authorFabiano Rosas <farosas@suse.de>
Mon, 26 Feb 2024 20:31:21 +0000 (17:31 -0300)
committerPeter Xu <peterx@redhat.com>
Wed, 28 Feb 2024 03:31:28 +0000 (11:31 +0800)
commit22b04245f0d5237b0e4f7b10fa05577eff6522ea
tree2c5054e918475f89c3fc1c66c733711fcc3b2d33
parent63f64d77f04337c21564fead6e9a55fdb2c80740
migration: Join the return path thread before releasing to_dst_file

The return path thread might hang at a blocking system call. Before
joining the thread we might need to issue a shutdown() on the socket
file descriptor to release it. To determine whether the shutdown() is
necessary we look at the QEMUFile error.

Make sure we only clean up the QEMUFile after the return path has been
waited for.

This fixes a hang when qemu_savevm_state_setup() produced an error
that was detected by migration_detect_error(). That skips
migration_completion() so close_return_path_on_source() would get
stuck waiting for the RP thread to terminate.

Reported-by: Cédric Le Goater <clg@redhat.com>
Tested-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Link: https://lore.kernel.org/r/20240226203122.22894-2-farosas@suse.de
Signed-off-by: Peter Xu <peterx@redhat.com>
migration/migration.c