All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 5/5] runstate: Allow user to migrate twice
Date: Fri, 14 Oct 2011 21:47:24 +0200	[thread overview]
Message-ID: <j7a3kd$knr$1@dough.gmane.org> (raw)
In-Reply-To: <1318613203-25892-6-git-send-email-lcapitulino@redhat.com>

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<lcapitulino@redhat.com>
> ---
>   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 <pbonzini@redhat.com>

Paolo

  reply	other threads:[~2011-10-14 20:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-14 17:26 [Qemu-devel] [PULL 0/5]: QMP queue Luiz Capitulino
2011-10-14 17:26 ` [Qemu-devel] [PATCH 1/5] QMP: Fix blockdev-snapshot-sync doc example Luiz Capitulino
2011-10-14 17:26 ` [Qemu-devel] [PATCH 2/5] runstate: Print state transition when invalid Luiz Capitulino
2011-10-19  0:43   ` Wen Congyang
2011-10-19 12:56     ` Luiz Capitulino
2011-10-14 17:26 ` [Qemu-devel] [PATCH 3/5] runstate: Allow to transition from paused to postmigrate Luiz Capitulino
2011-10-14 17:26 ` [Qemu-devel] [PATCH 4/5] savevm: qemu_savevm_state(): Drop stop VM logic Luiz Capitulino
2011-10-14 17:26 ` [Qemu-devel] [PATCH 5/5] runstate: Allow user to migrate twice Luiz Capitulino
2011-10-14 19:47   ` Paolo Bonzini [this message]
2011-10-20 15:01 ` [Qemu-devel] [PULL 0/5]: QMP queue Anthony Liguori
  -- strict thread matches above, loose matches on Subject: below --
2011-10-19 12:56 [Qemu-devel] [RESEND PULL " Luiz Capitulino
2011-10-19 12:56 ` [Qemu-devel] [PATCH 5/5] runstate: Allow user to migrate twice Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='j7a3kd$knr$1@dough.gmane.org' \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.