From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REoad-0004fD-JF for qemu-devel@nongnu.org; Fri, 14 Oct 2011 16:42:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REoaT-00047o-4g for qemu-devel@nongnu.org; Fri, 14 Oct 2011 16:42:46 -0400 Received: from lo.gmane.org ([80.91.229.12]:49514) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REoaS-000462-7q for qemu-devel@nongnu.org; Fri, 14 Oct 2011 16:42:36 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1REnjE-0005v5-Qq for qemu-devel@nongnu.org; Fri, 14 Oct 2011 21:47:36 +0200 Received: from 93-34-218-143.ip51.fastwebnet.it ([93.34.218.143]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Oct 2011 21:47:36 +0200 Received: from pbonzini by 93-34-218-143.ip51.fastwebnet.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Oct 2011 21:47:36 +0200 From: Paolo Bonzini Date: Fri, 14 Oct 2011 21:47:24 +0200 Message-ID: References: <1318613203-25892-1-git-send-email-lcapitulino@redhat.com> <1318613203-25892-6-git-send-email-lcapitulino@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit In-Reply-To: <1318613203-25892-6-git-send-email-lcapitulino@redhat.com> Subject: Re: [Qemu-devel] [PATCH 5/5] runstate: Allow user to migrate twice List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On 10/14/2011 07:26 PM, Luiz Capitulino wrote: > 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 2e991fc..103a0df 100644 > --- a/vl.c > +++ b/vl.c > @@ -339,17 +339,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 }, > @@ -369,8 +372,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 }, > }; Belatedly-Acked-by: Paolo Bonzini Paolo