From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZboAH-0003R8-MQ for qemu-devel@nongnu.org; Tue, 15 Sep 2015 07:12:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZboAE-0003Lx-AE for qemu-devel@nongnu.org; Tue, 15 Sep 2015 07:12:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZboAE-0003Ls-2w for qemu-devel@nongnu.org; Tue, 15 Sep 2015 07:12:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6D9EC8EA26 for ; Tue, 15 Sep 2015 11:12:41 +0000 (UTC) Date: Tue, 15 Sep 2015 16:42:26 +0530 From: Amit Shah Message-ID: <20150915111226.GF10281@grmbl.mre> References: <1439463094-5394-1-git-send-email-dgilbert@redhat.com> <1439463094-5394-3-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1439463094-5394-3-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/5] Split out end of migration code from migration_thread List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: qemu-devel@nongnu.org, quintela@redhat.com On (Thu) 13 Aug 2015 [11:51:31], Dr. David Alan Gilbert (git) wrote: > From: "Dr. David Alan Gilbert" > > The code that gets run at the end of the migration process > is getting large, and I'm about to add more for postcopy. > Split it into a separate function. > > Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Amit Shah > --- > migration/migration.c | 75 ++++++++++++++++++++++++++++++++------------------- > trace-events | 2 ++ > 2 files changed, 49 insertions(+), 28 deletions(-) > > diff --git a/migration/migration.c b/migration/migration.c > index 662e77e..46bb410 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -913,6 +913,50 @@ int64_t migrate_xbzrle_cache_size(void) > return s->xbzrle_cache_size; > } > > +/** > + * migration_completion: Used by migration_thread when there's not much left. > + * The caller 'breaks' the loop when this returns. > + * > + * @s: Current migration state > + * @*old_vm_running: Pointer to old_vm_running flag > + * @*start_time: Pointer to time to update > + */ > +static void migration_completion(MigrationState *s, bool *old_vm_running, > + int64_t *start_time) > +{ > + int ret; > + > + qemu_mutex_lock_iothread(); > + *start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); > + qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); > + *old_vm_running = runstate_is_running(); > + > + ret = global_state_store(); > + if (!ret) { > + ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); > + if (ret >= 0) { > + qemu_file_set_rate_limit(s->file, INT64_MAX); > + qemu_savevm_state_complete(s->file); > + } > + } The case where ret >= 0 and where s->file has an error didn't set status to failed nor break'ed in the removed context below. But it happened a few lines outside the context anyway. Now it just happens in this function, which is cleaner and easier to understand. Amit