From nobody Tue Nov 4 16:07:12 2025 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 1504083249120136.04709027967237; Wed, 30 Aug 2017 01:54:09 -0700 (PDT) Received: from localhost ([::1]:49108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmylD-0000AI-30 for importer@patchew.org; Wed, 30 Aug 2017 04:54:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmySy-0000XS-Vo for qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmySy-0004Gl-5t for qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46112) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmySy-0004GG-0q for qemu-devel@nongnu.org; Wed, 30 Aug 2017 04:35:16 -0400 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 114ABC04BD2C; Wed, 30 Aug 2017 08:35:15 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-14-103.nay.redhat.com [10.66.14.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D1B984792; Wed, 30 Aug 2017 08:35:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 114ABC04BD2C Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 30 Aug 2017 16:32:23 +0800 Message-Id: <1504081950-2528-27-git-send-email-peterx@redhat.com> In-Reply-To: <1504081950-2528-1-git-send-email-peterx@redhat.com> References: <1504081950-2528-1-git-send-email-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.31]); Wed, 30 Aug 2017 08:35:15 +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 v2 26/33] 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 Reviewed-by: Dr. David Alan Gilbert --- migration/migration.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 19aed72..c9b7085 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1694,7 +1694,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 */ + qemu_sem_post(&s->rp_state.rp_sem); =20 return 0; } @@ -2169,6 +2170,21 @@ typedef enum MigThrError { MIG_THR_ERR_FATAL =3D 2, } MigThrError; =20 +static int postcopy_resume_handshake(MigrationState *s) +{ + qemu_savevm_send_postcopy_resume(s->to_dst_file); + + while (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_RECOVER) { + qemu_sem_wait(&s->rp_state.rp_sem); + } + + 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) { @@ -2186,10 +2202,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