From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e3zGj-0000fn-Fz for qemu-devel@nongnu.org; Mon, 16 Oct 2017 02:52:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e3zGi-0001RJ-Ib for qemu-devel@nongnu.org; Mon, 16 Oct 2017 02:52:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37290) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e3zGi-0001QM-A7 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 02:52:56 -0400 From: Peter Xu Date: Mon, 16 Oct 2017 14:51:51 +0800 Message-Id: <20171016065216.18162-8-peterx@redhat.com> In-Reply-To: <20171016065216.18162-1-peterx@redhat.com> References: <20171016065216.18162-1-peterx@redhat.com> Subject: [Qemu-devel] [PATCH v3 07/32] migration: allow src return path to pause List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Andrea Arcangeli , "Daniel P . Berrange" , Juan Quintela , Alexey Perevalov , "Dr . David Alan Gilbert" , peterx@redhat.com Let the thread pause for network issues. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu --- migration/migration.c | 35 +++++++++++++++++++++++++++++++++-- migration/migration.h | 1 + migration/trace-events | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 3cc6d4933d..17a8ec39ef 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1078,6 +1078,7 @@ static void migrate_fd_cleanup(void *opaque) block_cleanup_parameters(s); qemu_sem_destroy(&s->postcopy_pause_sem); + qemu_sem_destroy(&s->postcopy_pause_rp_sem); } void migrate_fd_error(MigrationState *s, const Error *error) @@ -1222,6 +1223,7 @@ MigrationState *migrate_init(void) error_free(s->error); s->error = NULL; qemu_sem_init(&s->postcopy_pause_sem, 0); + qemu_sem_init(&s->postcopy_pause_rp_sem, 0); migrate_set_state(&s->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_SETUP); @@ -1641,6 +1643,18 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, } } +/* Return true to retry, false to quit */ +static bool postcopy_pause_return_path_thread(MigrationState *s) +{ + trace_postcopy_pause_return_path(); + + qemu_sem_wait(&s->postcopy_pause_rp_sem); + + trace_postcopy_pause_return_path_continued(); + + return true; +} + /* * Handles messages sent on the return path towards the source VM * @@ -1657,6 +1671,8 @@ static void *source_return_path_thread(void *opaque) int res; trace_source_return_path_thread_entry(); + +retry: while (!ms->rp_state.error && !qemu_file_get_error(rp) && migration_is_setup_or_active(ms->state)) { trace_source_return_path_thread_loop_top(); @@ -1748,13 +1764,28 @@ static void *source_return_path_thread(void *opaque) break; } } - if (qemu_file_get_error(rp)) { + +out: + res = qemu_file_get_error(rp); + if (res) { + if (res == -EIO) { + /* + * Maybe there is something we can do: it looks like a + * network down issue, and we pause for a recovery. + */ + if (postcopy_pause_return_path_thread(ms)) { + /* Reload rp, reset the rest */ + rp = ms->rp_state.from_dst_file; + ms->rp_state.error = false; + goto retry; + } + } + trace_source_return_path_thread_bad_end(); mark_source_rp_bad(ms); } trace_source_return_path_thread_end(); -out: ms->rp_state.from_dst_file = NULL; qemu_fclose(rp); return NULL; diff --git a/migration/migration.h b/migration/migration.h index 1280060d54..6776405edb 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -156,6 +156,7 @@ struct MigrationState /* Needed by postcopy-pause state */ QemuSemaphore postcopy_pause_sem; + QemuSemaphore postcopy_pause_rp_sem; }; void migrate_set_state(int *state, int old_state, int new_state); diff --git a/migration/trace-events b/migration/trace-events index bed1646cd6..a4031cfe00 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -99,6 +99,8 @@ migration_thread_setup_complete(void) "" open_return_path_on_source(void) "" open_return_path_on_source_continue(void) "" postcopy_start(void) "" +postcopy_pause_return_path(void) "" +postcopy_pause_return_path_continued(void) "" postcopy_pause_continued(void) "" postcopy_pause_incoming(void) "" postcopy_pause_incoming_continued(void) "" -- 2.13.5