From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeMIZ-0005nn-Pi for qemu-devel@nongnu.org; Thu, 07 Nov 2013 04:54:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeMIV-0000ck-0p for qemu-devel@nongnu.org; Thu, 07 Nov 2013 04:54:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeMIU-0000cW-O0 for qemu-devel@nongnu.org; Thu, 07 Nov 2013 04:54:42 -0500 Message-ID: <527B6354.2060406@redhat.com> Date: Thu, 07 Nov 2013 10:54:28 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [patch] avoid a bogus COMPLETED->CANCELLED transition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Zhanghaoyu (A)" Cc: "Huangweidong (C)" , Gleb Natapov , "Michael S. Tsirkin" , Marcelo Tosatti , Luonengjun , "qemu-devel@nongnu.org" , Zengjunliang , "Wangrui (K)" Il 07/11/2013 09:21, Zhanghaoyu (A) ha scritto: > Avoid a bogus COMPLETED->CANCELLED transition. > There is a period of time from the timing of setting COMPLETED state to that of migration thread exits, so during which it's problematic in COMPLETED->CANCELLED transition. > > Signed-off-by: Zeng Junliang > Signed-off-by: Zhang Haoyu > --- > migration.c | 9 ++++++++- > 1 files changed, 8 insertions(+), 1 deletions(-) > > diff --git a/migration.c b/migration.c > index 2b1ab20..fd73b97 100644 > --- a/migration.c > +++ b/migration.c > @@ -326,9 +326,16 @@ void migrate_fd_error(MigrationState *s) > > static void migrate_fd_cancel(MigrationState *s) > { > + int old_state ; > DPRINTF("cancelling migration\n"); > > - migrate_set_state(s, s->state, MIG_STATE_CANCELLED); > + do { > + old_state = s->state; > + if (old_state != MIG_STATE_SETUP && old_state != MIG_STATE_ACTIVE) { > + break; > + } > + migrate_set_state(s, old_state, MIG_STATE_CANCELLED); > + } while (s->state != MIG_STATE_CANCELLED); > } > > void add_migration_state_change_notifier(Notifier *notify) > Reviewed-by: Paolo Bonzini