This will be used in the next patch to allow COLO to reuse the return path.
Signed-off-by: Lukas Straub <[email protected]> --- migration/migration.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index f36d42ef657bdf26d78ca642d77a9b76e1c0c174..74f5c314ff62333f6c9dd8bbd09afdfaf84a41c2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -97,7 +97,8 @@ static GSList *migration_blockers[MIG_MODE__MAX]; static bool migration_object_check(MigrationState *ms, Error **errp); static bool migration_switchover_start(MigrationState *s, Error **errp); -static bool close_return_path_on_source(MigrationState *s); +static bool stop_return_path_thread_on_source(MigrationState *s); +static void migration_release_dst_files(MigrationState *ms); static void migration_completion_end(MigrationState *s); static void migration_downtime_start(MigrationState *s) @@ -1278,7 +1279,8 @@ static void migration_cleanup(MigrationState *s) cpr_state_close(); cpr_transfer_source_destroy(s); - close_return_path_on_source(s); + stop_return_path_thread_on_source(s); + migration_release_dst_files(s); if (s->migration_thread_running) { bql_unlock(); @@ -2209,6 +2211,7 @@ static void migration_release_dst_files(MigrationState *ms) * locking needed because this qemufile should only be managed by * return path thread. */ + assert(!ms->rp_state.rp_thread_created); if (ms->postcopy_qemufile_src) { migration_ioc_unregister_yank_from_file(ms->postcopy_qemufile_src); qemu_file_shutdown(ms->postcopy_qemufile_src); @@ -2216,7 +2219,9 @@ static void migration_release_dst_files(MigrationState *ms) ms->postcopy_qemufile_src = NULL; } - qemu_fclose(file); + if (file) { + qemu_fclose(file); + } } /* @@ -2402,7 +2407,7 @@ static void open_return_path_on_source(MigrationState *ms) } /* Return true if error detected, or false otherwise */ -static bool close_return_path_on_source(MigrationState *ms) +static bool stop_return_path_thread_on_source(MigrationState *ms) { if (!ms->rp_state.rp_thread_created) { return false; @@ -2424,7 +2429,6 @@ static bool close_return_path_on_source(MigrationState *ms) qemu_thread_join(&ms->rp_state.rp_thread); ms->rp_state.rp_thread_created = false; - migration_release_dst_files(ms); trace_migration_return_path_end_after(); /* Return path will persist the error in MigrationState when quit */ @@ -2787,7 +2791,7 @@ static void migration_completion(MigrationState *s) goto fail; } - if (close_return_path_on_source(s)) { + if (stop_return_path_thread_on_source(s)) { goto fail; } @@ -2941,7 +2945,8 @@ static MigThrError postcopy_pause(MigrationState *s) * path and just wait for the thread to finish. It will be * re-created when we resume. */ - close_return_path_on_source(s); + stop_return_path_thread_on_source(s); + migration_release_dst_files(s); /* * Current channel is possibly broken. Release it. Note that this is -- 2.39.5
