From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REih2-0001dZ-Or for qemu-devel@nongnu.org; Fri, 14 Oct 2011 10:25:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REih0-0003Ll-QD for qemu-devel@nongnu.org; Fri, 14 Oct 2011 10:25:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REih0-0003Lg-DQ for qemu-devel@nongnu.org; Fri, 14 Oct 2011 10:24:58 -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 p9EEOvM4011353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Oct 2011 10:24:57 -0400 Date: Fri, 14 Oct 2011 11:24:55 -0300 From: Luiz Capitulino Message-ID: <20111014112455.2d2d147b@doriath> In-Reply-To: <4E983B19.90707@redhat.com> References: <20111010155013.0c1e40c4@doriath> <1318317762-20956-1-git-send-email-pbonzini@redhat.com> <20111011145248.4ef5e39b@doriath> <20111013172626.2cd925bc@doriath> <4E97DD39.9070601@redhat.com> <20111014102346.249f41f6@doriath> <4E983B19.90707@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Fri, 14 Oct 2011 15:37:29 +0200 Paolo Bonzini wrote: > On 10/14/2011 03:23 PM, Luiz Capitulino wrote: > > I'm not, because I'm assuming that allowing a transition from 'paused' to > > 'postmigrate' plus this fix: > > > > http://lists.gnu.org/archive/html/qemu-devel/2011-10/msg01430.html > > I think POST_MIGRATE -> FINISH_MIGRATE should be still allowed in case > you migrate twice. Management would probably disallow that, but from > the monitor you can do funny things: stop the machine, create two images > based on the running machine's image, and migrate to both images. Yes, you're right. But there's another problem there: the VM is stopped when the migration process finishes. So, if you migrate again, there won't be a POST_MIGRATE -> FINISH_MIGRATE transition, as vm_stop() will just return. I don't like the idea of changing current vm_stop() to always change the state, so I'm adding a new function to do that: 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 2e991fc..613204b 100644 --- a/vl.c +++ b/vl.c @@ -346,6 +346,7 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_PAUSED, RUN_STATE_POSTMIGRATE }, { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, + { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, -- 1.7.7.rc3