From nobody Tue Feb 10 12:57:58 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150122997126260.357770198278104; Fri, 28 Jul 2017 01:19:31 -0700 (PDT) Received: from localhost ([::1]:46705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1db0Ub-0005Nu-O9 for importer@patchew.org; Fri, 28 Jul 2017 04:19:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1db0K2-0001l0-NO for qemu-devel@nongnu.org; Fri, 28 Jul 2017 04:08:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1db0K1-0001rD-PO for qemu-devel@nongnu.org; Fri, 28 Jul 2017 04:08:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1db0K1-0001qi-GB for qemu-devel@nongnu.org; Fri, 28 Jul 2017 04:08:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B9E0F8028; Fri, 28 Jul 2017 08:08:32 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73DB9600C2; Fri, 28 Jul 2017 08:08:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B9E0F8028 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 28 Jul 2017 16:06:37 +0800 Message-Id: <1501229198-30588-29-git-send-email-peterx@redhat.com> In-Reply-To: <1501229198-30588-1-git-send-email-peterx@redhat.com> References: <1501229198-30588-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 28 Jul 2017 08:08:32 +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] [RFC 28/29] migration: final handshake for the resume 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: Laurent Vivier , 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" Finish the last step to do the final handshake for the recovery. First source sends one MIG_CMD_RESUME to dst, telling that source is ready to resume. Then, dest replies with MIG_RP_MSG_RESUME_ACK to source, telling that dest is ready to resume (after switch to postcopy-active state). When source received the RESUME_ACK, it switches its state to postcopy-active, and finally the recovery is completed. Signed-off-by: Peter Xu --- migration/migration.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 93fbc96..ecebe30 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1666,6 +1666,13 @@ static int migrate_handle_rp_recv_bitmap(MigrationSt= ate *s, char *block_name) return ram_dirty_bitmap_reload(s, block); } =20 +static void postcopy_resume_handshake_ack(MigrationState *s) +{ + qemu_mutex_lock(&s->resume_lock); + qemu_cond_signal(&s->resume_cond); + qemu_mutex_unlock(&s->resume_lock); +} + static int migrate_handle_rp_resume_ack(MigrationState *s, uint32_t value) { trace_source_return_path_thread_resume_ack(value); @@ -1680,7 +1687,8 @@ static int migrate_handle_rp_resume_ack(MigrationStat= e *s, uint32_t value) migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER, MIGRATION_STATUS_POSTCOPY_ACTIVE); =20 - /* TODO: notify send thread that time to continue send pages */ + /* Notify send thread that time to continue send pages */ + postcopy_resume_handshake_ack(s); =20 return 0; } @@ -2151,6 +2159,25 @@ static bool postcopy_should_start(MigrationState *s) return atomic_read(&s->start_postcopy) || s->start_postcopy_fast; } =20 +static int postcopy_resume_handshake(MigrationState *s) +{ + qemu_mutex_lock(&s->resume_lock); + + qemu_savevm_send_postcopy_resume(s->to_dst_file); + + while (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_RECOVER) { + qemu_cond_wait(&s->resume_cond, &s->resume_lock); + } + + qemu_mutex_unlock(&s->resume_lock); + + if (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE) { + return 0; + } + + return -1; +} + /* Return zero if success, or <0 for error */ static int postcopy_do_resume(MigrationState *s) { @@ -2168,10 +2195,14 @@ static int postcopy_do_resume(MigrationState *s) } =20 /* - * TODO: handshake with dest using MIG_CMD_RESUME, - * MIG_RP_MSG_RESUME_ACK, then switch source state to - * "postcopy-active" + * Last handshake with destination on the resume (destination will + * switch to postcopy-active afterwards) */ + ret =3D postcopy_resume_handshake(s); + if (ret) { + error_report("%s: handshake failed: %d", __func__, ret); + return ret; + } =20 return 0; } --=20 2.7.4