From patchwork Tue Dec 5 06:52:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 844604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yrXjc5FJdz9sNr for ; Tue, 5 Dec 2017 18:01:53 +1100 (AEDT) Received: from localhost ([::1]:46868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eM7El-0007LE-OU for incoming@patchwork.ozlabs.org; Tue, 05 Dec 2017 02:01:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eM76s-00085w-7j for qemu-devel@nongnu.org; Tue, 05 Dec 2017 01:53:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eM76p-0003RU-Ov for qemu-devel@nongnu.org; Tue, 05 Dec 2017 01:53:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eM76p-0003R9-Fk for qemu-devel@nongnu.org; Tue, 05 Dec 2017 01:53:39 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B7697EBD5; Tue, 5 Dec 2017 06:53:38 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-111.nay.redhat.com [10.66.14.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22A0D17D48; Tue, 5 Dec 2017 06:53:34 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 5 Dec 2017 14:52:46 +0800 Message-Id: <20171205065307.21853-8-peterx@redhat.com> In-Reply-To: <20171205065307.21853-1-peterx@redhat.com> References: <20171205065307.21853-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 05 Dec 2017 06:53:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 07/28] migration: allow src return path to pause X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrea Arcangeli , Juan Quintela , Alexey Perevalov , peterx@redhat.com, "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 6f0d48bbed..0dfbbe5673 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1689,6 +1689,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 * @@ -1705,6 +1717,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(); @@ -1796,13 +1810,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; @@ -2557,6 +2586,7 @@ static void migration_instance_finalize(Object *obj) g_free(params->tls_creds); qemu_sem_destroy(&ms->pause_sem); qemu_sem_destroy(&ms->postcopy_pause_sem); + qemu_sem_destroy(&ms->postcopy_pause_rp_sem); } static void migration_instance_init(Object *obj) @@ -2587,6 +2617,7 @@ static void migration_instance_init(Object *obj) params->has_xbzrle_cache_size = true; qemu_sem_init(&ms->postcopy_pause_sem, 0); + qemu_sem_init(&ms->postcopy_pause_rp_sem, 0); } /* diff --git a/migration/migration.h b/migration/migration.h index 55894ecb79..ebb049f692 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -162,6 +162,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) ""