From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvMZF-0003Cg-PN for qemu-devel@nongnu.org; Fri, 22 Sep 2017 07:56:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvMZA-0000GM-7B for qemu-devel@nongnu.org; Fri, 22 Sep 2017 07:56:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60014) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dvMZ9-0000Dm-VX for qemu-devel@nongnu.org; Fri, 22 Sep 2017 07:56:20 -0400 Date: Fri, 22 Sep 2017 12:56:12 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20170922115612.GJ2620@work-vm> References: <1504081950-2528-1-git-send-email-peterx@redhat.com> <1504081950-2528-27-git-send-email-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1504081950-2528-27-git-send-email-peterx@redhat.com> Subject: Re: [Qemu-devel] [RFC v2 26/33] migration: final handshake for the resume List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: qemu-devel@nongnu.org, Laurent Vivier , "Daniel P . Berrange" , Alexey Perevalov , Juan Quintela , Andrea Arcangeli * Peter Xu (peterx@redhat.com) wrote: > 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(MigrationState *s, uint32_t value) > migrate_set_state(&s->state, MIGRATION_STATUS_POSTCOPY_RECOVER, > MIGRATION_STATUS_POSTCOPY_ACTIVE); > > - /* 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); > > return 0; > } > @@ -2169,6 +2170,21 @@ typedef enum MigThrError { > MIG_THR_ERR_FATAL = 2, > } MigThrError; > > +static int postcopy_resume_handshake(MigrationState *s) > +{ > + qemu_savevm_send_postcopy_resume(s->to_dst_file); > + > + while (s->state == MIGRATION_STATUS_POSTCOPY_RECOVER) { > + qemu_sem_wait(&s->rp_state.rp_sem); > + } > + > + if (s->state == 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) > } > > /* > - * 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 = postcopy_resume_handshake(s); > + if (ret) { > + error_report("%s: handshake failed: %d", __func__, ret); > + return ret; > + } > > return 0; > } > -- > 2.7.4 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK