Skip to content

Commit

Permalink
migration: Move return path cleanup to main migration thread
Browse files Browse the repository at this point in the history
Now that the return path thread is allowed to finish during a paused
migration, we can move the cleanup of the QEMUFiles to the main
migration thread.

Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230918172822.19052-9-farosas@suse.de>
(cherry picked from commit 36e9aab)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
Fabiano Rosas authored and Michael Tokarev committed Oct 2, 2023
1 parent dec7785 commit 4ade907
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion migration/migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static int migration_maybe_pause(MigrationState *s,
int *current_active_state,
int new_state);
static void migrate_fd_cancel(MigrationState *s);
static int await_return_path_close_on_source(MigrationState *s);

static bool migration_needs_multiple_sockets(void)
{
Expand Down Expand Up @@ -1178,6 +1179,12 @@ static void migrate_fd_cleanup(MigrationState *s)
qemu_fclose(tmp);
}

/*
* We already cleaned up to_dst_file, so errors from the return
* path might be due to that, ignore them.
*/
await_return_path_close_on_source(s);

assert(!migration_is_active(s));

if (s->state == MIGRATION_STATUS_CANCELLING) {
Expand Down Expand Up @@ -1986,7 +1993,6 @@ static void *source_return_path_thread(void *opaque)
}

trace_source_return_path_thread_end();
migration_release_dst_files(ms);
rcu_unregister_thread();
return NULL;
}
Expand Down Expand Up @@ -2040,6 +2046,9 @@ static int await_return_path_close_on_source(MigrationState *ms)

ret = ms->rp_state.error;
ms->rp_state.error = false;

migration_release_dst_files(ms);

trace_migration_return_path_end_after(ret);
return ret;
}
Expand Down

0 comments on commit 4ade907

Please sign in to comment.