[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 5/8] migration: Consolidate return path closing code
From: |
Fabiano Rosas |
Subject: |
[PATCH v4 5/8] migration: Consolidate return path closing code |
Date: |
Wed, 16 Aug 2023 11:25:07 -0300 |
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 <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/migration.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/migration/migration.c b/migration/migration.c
index 195726eb4a..4edbee3a5d 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -2049,6 +2049,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
@@ -2066,7 +2074,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
@@ -2362,20 +2373,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)) {
--
2.35.3
- [PATCH v4 0/8] Fix segfault on migration return path, Fabiano Rosas, 2023/08/16
- [PATCH v4 1/8] migration: Fix possible race when setting rp_state.error, Fabiano Rosas, 2023/08/16
- [PATCH v4 3/8] migration: Fix possible race when shutting down to_dst_file, Fabiano Rosas, 2023/08/16
- [PATCH v4 2/8] migration: Fix possible races when shutting down the return path, Fabiano Rosas, 2023/08/16
- [PATCH v4 5/8] migration: Consolidate return path closing code,
Fabiano Rosas <=
- [PATCH v4 4/8] migration: Remove redundant cleanup of postcopy_qemufile_src, Fabiano Rosas, 2023/08/16
- [PATCH v4 6/8] migration: Replace the return path retry logic, Fabiano Rosas, 2023/08/16
- [PATCH v4 7/8] migration: Move return path cleanup to main migration thread, Fabiano Rosas, 2023/08/16
- [PATCH v4 8/8] migration: Add a wrapper to cleanup migration files, Fabiano Rosas, 2023/08/16