diff --git a/migration/migration.c b/migration/migration.c index 2ec116f9010f0ca8865855868113cea242db01ce..155ed2b4095a89cd9ce8bcbd74ef65c6ca696799 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2955,6 +2955,13 @@ static int open_return_path_on_source(MigrationState *ms, /* Returns 0 if the RP was ok, otherwise there was an error on the RP */ static int await_return_path_close_on_source(MigrationState *ms) { + int ret; + + if (!ms->rp_state.rp_thread_created) { + return 0; + } + + trace_migration_return_path_end_before(); /* * If this is a normal exit then the destination will send a SHUT and the * rp_thread will exit, however if there's an error we need to cause @@ -2972,7 +2979,9 @@ static int await_return_path_close_on_source(MigrationState *ms) qemu_thread_join(&ms->rp_state.rp_thread); ms->rp_state.rp_thread_created = false; trace_await_return_path_close_on_source_close(); - return ms->rp_state.error; + ret = ms->rp_state.error; + trace_migration_return_path_end_after(ret); + return ret; } /* @@ -3247,21 +3256,8 @@ static void migration_completion(MigrationState *s) goto fail; } - /* - * If rp was opened we must clean up the thread before - * cleaning everything else up (since if there are no failures - * it will wait for the destination to send it's status in - * a SHUT command). - */ - if (s->rp_state.rp_thread_created) { - int rp_error; - trace_migration_return_path_end_before(); - rp_error = await_return_path_close_on_source(s); - trace_migration_return_path_end_after(rp_error); - if (rp_error) { - goto fail_invalidate; - } - } + if (await_return_path_close_on_source(s)) { + goto fail; if (qemu_file_get_error(s->to_dst_file)) { trace_migration_completion_file_err();