From nobody Mon Feb 9 04:44:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518086066382798.0889729608; Thu, 8 Feb 2018 02:34:26 -0800 (PST) Received: from localhost ([::1]:41035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejjX6-0007t2-Em for importer@patchew.org; Thu, 08 Feb 2018 05:34:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ejjUl-0006Pg-F5 for qemu-devel@nongnu.org; Thu, 08 Feb 2018 05:32:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ejjUk-0005Ue-FH for qemu-devel@nongnu.org; Thu, 08 Feb 2018 05:31:59 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37320 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ejjUk-0005UU-Ak for qemu-devel@nongnu.org; Thu, 08 Feb 2018 05:31:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2F478185352; Thu, 8 Feb 2018 10:31:57 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-120.nay.redhat.com [10.66.14.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CCF82166BAE; Thu, 8 Feb 2018 10:31:55 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 8 Feb 2018 18:31:11 +0800 Message-Id: <20180208103132.28452-8-peterx@redhat.com> In-Reply-To: <20180208103132.28452-1-peterx@redhat.com> References: <20180208103132.28452-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 10:31:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 10:31:57 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v6 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 fc0d0e0e31..5c3b701102 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1688,6 +1688,18 @@ static void migrate_handle_rp_req_pages(MigrationSta= te *ms, const char* rbname, } } =20 +/* 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 * @@ -1704,6 +1716,8 @@ static void *source_return_path_thread(void *opaque) int res; =20 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(); @@ -1795,13 +1809,28 @@ static void *source_return_path_thread(void *opaque) break; } } - if (qemu_file_get_error(rp)) { + +out: + res =3D qemu_file_get_error(rp); + if (res) { + if (res =3D=3D -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 =3D ms->rp_state.from_dst_file; + ms->rp_state.error =3D false; + goto retry; + } + } + trace_source_return_path_thread_bad_end(); mark_source_rp_bad(ms); } =20 trace_source_return_path_thread_end(); -out: ms->rp_state.from_dst_file =3D NULL; qemu_fclose(rp); return NULL; @@ -2609,6 +2638,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); } =20 static void migration_instance_init(Object *obj) @@ -2639,6 +2669,7 @@ static void migration_instance_init(Object *obj) params->has_xbzrle_cache_size =3D true; =20 qemu_sem_init(&ms->postcopy_pause_sem, 0); + qemu_sem_init(&ms->postcopy_pause_rp_sem, 0); } =20 /* diff --git a/migration/migration.h b/migration/migration.h index 27ba256c40..765bd9f5bd 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -184,6 +184,7 @@ struct MigrationState =20 /* Needed by postcopy-pause state */ QemuSemaphore postcopy_pause_sem; + QemuSemaphore postcopy_pause_rp_sem; }; =20 void migrate_set_state(int *state, int old_state, int new_state); diff --git a/migration/trace-events b/migration/trace-events index 8685a62c98..ca17a70222 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) "" --=20 2.14.3