From patchwork Tue Jul 16 16:48:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mrhines@linux.vnet.ibm.com X-Patchwork-Id: 259474 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AA3102C0156 for ; Wed, 17 Jul 2013 03:29:43 +1000 (EST) Received: from localhost ([::1]:34818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uz8TP-0000FX-FV for incoming@patchwork.ozlabs.org; Tue, 16 Jul 2013 12:51:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uz8Qz-0006CY-Fa for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:49:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uz8Qu-0000Zk-9i for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:49:05 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:48752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uz8Qu-0000ZN-2b for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:49:00 -0400 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Jul 2013 10:48:58 -0600 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e39.co.us.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 16 Jul 2013 10:48:55 -0600 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id CDDCA38C8039 for ; Tue, 16 Jul 2013 12:48:53 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6GGmsqX053062 for ; Tue, 16 Jul 2013 12:48:54 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r6GGmiRn001056 for ; Tue, 16 Jul 2013 13:48:45 -0300 Received: from mrhinesdev.klabtestbed.com (klinux.watson.ibm.com [9.2.208.21]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r6GGmTue000589; Tue, 16 Jul 2013 13:48:44 -0300 From: mrhines@linux.vnet.ibm.com To: qemu-devel@nongnu.org Date: Tue, 16 Jul 2013 12:48:24 -0400 Message-Id: <1373993306-25764-7-git-send-email-mrhines@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373993306-25764-1-git-send-email-mrhines@linux.vnet.ibm.com> References: <1373993306-25764-1-git-send-email-mrhines@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13071616-3620-0000-0000-0000038AF43A X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.110.160 Cc: aliguori@us.ibm.com, quintela@redhat.com, knoel@redhat.com, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com, pbonzini@redhat.com, chegu_vinod@hp.com Subject: [Qemu-devel] [PATCH v3 resend 6/8] rdma: allow state transitions between other states besides ACTIVE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Michael R. Hines" This patch is in preparation for the next ones: Until now the MIG_STATE_SETUP state was not really a 'formal' state. It has been used as a 'zero' state and QEMU has been unconditionally transitioning into this state when the QMP migrate command was called. In preparation for timing this state, we have to make this state a a 'real' state which actually gets transitioned from later in the migration_thread() from SETUP => ACTIVE, rather than just automatically dropping into this state at the beginninig of the migration. This means that the state transition function (migration_finish_set_state()) needs to be capable of transitioning from valid states _other_ than just MIG_STATE_ACTIVE. The function is in fact already capable of doing that, but was not allowing the old state to be a parameter specified as an input. This patch fixes that and only makes the transition if the current state matches the old state that the caller intended to transition from. Reviewed-by: Juan Quintela Tested-by: Michael R. Hines Signed-off-by: Michael R. Hines --- migration.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migration.c b/migration.c index 2bfe245..d212871 100644 --- a/migration.c +++ b/migration.c @@ -295,9 +295,9 @@ static void migrate_fd_cleanup(void *opaque) notifier_list_notify(&migration_state_notifiers, s); } -static void migrate_finish_set_state(MigrationState *s, int new_state) +static void migrate_set_state(MigrationState *s, int old_state, int new_state) { - if (atomic_cmpxchg(&s->state, MIG_STATE_ACTIVE, new_state) == new_state) { + if (atomic_cmpxchg(&s->state, old_state, new_state) == new_state) { trace_migrate_set_state(new_state); } } @@ -315,7 +315,7 @@ static void migrate_fd_cancel(MigrationState *s) { DPRINTF("cancelling migration\n"); - migrate_finish_set_state(s, MIG_STATE_CANCELLED); + migrate_set_state(s, s->state, MIG_STATE_CANCELLED); } void add_migration_state_change_notifier(Notifier *notify) @@ -545,14 +545,14 @@ static void *migration_thread(void *opaque) qemu_savevm_state_complete(s->file); qemu_mutex_unlock_iothread(); if (!qemu_file_get_error(s->file)) { - migrate_finish_set_state(s, MIG_STATE_COMPLETED); + migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_COMPLETED); break; } } } if (qemu_file_get_error(s->file)) { - migrate_finish_set_state(s, MIG_STATE_ERROR); + migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_ERROR); break; } current_time = qemu_get_clock_ms(rt_clock);