@samitouri / QOSamiQemu / commits / 64763e8ca6

migration: Keep s->rp_state.from_dst_file open until migration ends

This will be used in the next patch to allow COLO to reuse the return path. 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-20-d653fb3b1d80@web.de Signed-off-by: Fabiano Rosas <farosas@suse.de>

Lukas Straub committed Mar 2, 2026 at 12:45 UTC 64763e8ca61cec4caf3f0599a04db1ac08ba104d
1 file changed +12 -7
migration/migration.c
+12 -7
@@ -97,7 +97,8 @@ static GSList *migration_blockers[MIG_MODE__MAX];
97
98 static bool migration_object_check(MigrationState *ms, Error **errp);
99 static bool migration_switchover_start(MigrationState *s, Error **errp);
100 -static bool close_return_path_on_source(MigrationState *s);
100 +static bool stop_return_path_thread_on_source(MigrationState *s);
101 +static void migration_release_dst_files(MigrationState *ms);
102 static void migration_completion_end(MigrationState *s);
103
104 static void migration_downtime_start(MigrationState *s)
@@ -1281,7 +1282,8 @@ static void migration_cleanup(MigrationState *s)
1282 cpr_state_close();
1283 cpr_transfer_source_destroy(s);
1284
1284 - close_return_path_on_source(s);
1285 + stop_return_path_thread_on_source(s);
1286 + migration_release_dst_files(s);
1287
1288 if (s->migration_thread_running) {
1289 bql_unlock();
@@ -2217,6 +2219,7 @@ static void migration_release_dst_files(MigrationState *ms)
2219 * locking needed because this qemufile should only be managed by
2220 * return path thread.
2221 */
2222 + assert(!ms->rp_state.rp_thread_created);
2223 if (ms->postcopy_qemufile_src) {
2224 migration_ioc_unregister_yank_from_file(ms->postcopy_qemufile_src);
2225 qemu_file_shutdown(ms->postcopy_qemufile_src);
@@ -2224,7 +2227,9 @@ static void migration_release_dst_files(MigrationState *ms)
2227 ms->postcopy_qemufile_src = NULL;
2228 }
2229
2227 - qemu_fclose(file);
2230 + if (file) {
2231 + qemu_fclose(file);
2232 + }
2233 }
2234
2235 /*
@@ -2410,7 +2415,7 @@ static void open_return_path_on_source(MigrationState *ms)
2415 }
2416
2417 /* Return true if error detected, or false otherwise */
2413 -static bool close_return_path_on_source(MigrationState *ms)
2418 +static bool stop_return_path_thread_on_source(MigrationState *ms)
2419 {
2420 if (!ms->rp_state.rp_thread_created) {
2421 return false;
@@ -2432,7 +2437,6 @@ static bool close_return_path_on_source(MigrationState *ms)
2437
2438 qemu_thread_join(&ms->rp_state.rp_thread);
2439 ms->rp_state.rp_thread_created = false;
2435 - migration_release_dst_files(ms);
2440 trace_migration_return_path_end_after();
2441
2442 /* Return path will persist the error in MigrationState when quit */
@@ -2795,7 +2799,7 @@ static void migration_completion(MigrationState *s)
2799 goto fail;
2800 }
2801
2798 - if (close_return_path_on_source(s)) {
2802 + if (stop_return_path_thread_on_source(s)) {
2803 goto fail;
2804 }
2805
@@ -2949,7 +2953,8 @@ static MigThrError postcopy_pause(MigrationState *s)
2953 * path and just wait for the thread to finish. It will be
2954 * re-created when we resume.
2955 */
2952 - close_return_path_on_source(s);
2956 + stop_return_path_thread_on_source(s);
2957 + migration_release_dst_files(s);
2958
2959 /*
2960 * Current channel is possibly broken. Release it. Note that this is