Skip to content

Commit

Permalink
migration: Consolidate return path closing code
Browse files Browse the repository at this point in the history
We'll start calling the await_return_path_close_on_source() function
from other parts of the code, so move all of the related checks and
tracepoints into it.

Reviewed-by: Peter Xu <[email protected]>
Signed-off-by: Fabiano Rosas <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Message-ID: <[email protected]>
  • Loading branch information
Fabiano Rosas authored and stefanhaRH committed Sep 27, 2023
1 parent b3b1011 commit d50f5dc
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,14 @@ 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
Expand All @@ -2078,7 +2086,10 @@ 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;
}

static inline void
Expand Down Expand Up @@ -2374,20 +2385,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;
}
if (await_return_path_close_on_source(s)) {
goto fail;
}

if (qemu_file_get_error(s->to_dst_file)) {
Expand Down

0 comments on commit d50f5dc

Please sign in to comment.