From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lVI-0001MG-DY for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:40:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2lVD-0006Ue-Lo for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:40:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2lVD-0006UW-D9 for qemu-devel@nongnu.org; Mon, 13 Jan 2014 12:40:43 -0500 From: Juan Quintela Date: Mon, 13 Jan 2014 18:39:46 +0100 Message-Id: <1389634834-24181-2-git-send-email-quintela@redhat.com> In-Reply-To: <1389634834-24181-1-git-send-email-quintela@redhat.com> References: <1389634834-24181-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 01/49] avoid a bogus COMPLETED->CANCELLED transition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Zeng Junliang , "Zhanghaoyu (A)" , anthony@codemonkey.ws From: "Zhanghaoyu (A)" 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 Reviewed-by: Paolo Bonzini Signed-off-by: Juan Quintela --- migration.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) -- 1.8.4.2