From patchwork Wed Oct 19 12:56:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 120629 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B2F95B71BB for ; Thu, 20 Oct 2011 00:28:50 +1100 (EST) Received: from localhost ([::1]:59954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGViS-0000do-At for incoming@patchwork.ozlabs.org; Wed, 19 Oct 2011 08:57:52 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGVhm-0007UN-ME for qemu-devel@nongnu.org; Wed, 19 Oct 2011 08:57:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGVhk-0007qP-Jt for qemu-devel@nongnu.org; Wed, 19 Oct 2011 08:57:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5249) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGVhj-0007po-VE for qemu-devel@nongnu.org; Wed, 19 Oct 2011 08:57:08 -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 (8.14.4/8.14.4) with ESMTP id p9JCv4aV004670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Oct 2011 08:57:04 -0400 Received: from localhost (ovpn-113-110.phx2.redhat.com [10.3.113.110]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9JCv3KB028988; Wed, 19 Oct 2011 08:57:04 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Wed, 19 Oct 2011 10:56:51 -0200 Message-Id: <1319029011-11706-6-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1319029011-11706-1-git-send-email-lcapitulino@redhat.com> References: <1319029011-11706-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 5/5] runstate: Allow user to migrate twice 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 It should be a matter of allowing the transition POSTMIGRATE -> FINISH_MIGRATE, but it turns out that the VM won't do the transition the second time because it's already stopped. So this commit also adds vm_stop_force_state() which performs the transition even if the VM is already stopped. While there also allow other states to migrate. Signed-off-by: Luiz Capitulino --- cpus.c | 11 +++++++++++ migration.c | 2 +- sysemu.h | 1 + vl.c | 9 +++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/cpus.c b/cpus.c index 8978779..5f5b763 100644 --- a/cpus.c +++ b/cpus.c @@ -887,6 +887,17 @@ void vm_stop(RunState state) do_vm_stop(state); } +/* does a state transition even if the VM is already stopped, + current state is forgotten forever */ +void vm_stop_force_state(RunState state) +{ + if (runstate_is_running()) { + vm_stop(state); + } else { + runstate_set(state); + } +} + static int tcg_cpu_exec(CPUState *env) { int ret; diff --git a/migration.c b/migration.c index 77a51ad..62b74a6 100644 --- a/migration.c +++ b/migration.c @@ -375,7 +375,7 @@ void migrate_fd_put_ready(void *opaque) int old_vm_running = runstate_is_running(); DPRINTF("done iterating\n"); - vm_stop(RUN_STATE_FINISH_MIGRATE); + vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); if ((qemu_savevm_state_complete(s->mon, s->file)) < 0) { if (old_vm_running) { diff --git a/sysemu.h b/sysemu.h index a889d90..7d288f8 100644 --- a/sysemu.h +++ b/sysemu.h @@ -35,6 +35,7 @@ void vm_state_notify(int running, RunState state); void vm_start(void); void vm_stop(RunState state); +void vm_stop_force_state(RunState state); void qemu_system_reset_request(void); void qemu_system_shutdown_request(void); diff --git a/vl.c b/vl.c index 3e5fdf5..fff2b4c 100644 --- a/vl.c +++ b/vl.c @@ -337,17 +337,20 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_INMIGRATE, RUN_STATE_PRELAUNCH }, { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED }, + { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING }, + { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PAUSED, RUN_STATE_RUNNING }, - { RUN_STATE_PAUSED, RUN_STATE_POSTMIGRATE }, + { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, + { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, + { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, - { RUN_STATE_PRELAUNCH, RUN_STATE_POSTMIGRATE }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, @@ -367,8 +370,10 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, + { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, + { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_MAX, RUN_STATE_MAX }, };