From: Luiz Capitulino <lcapitulino@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions
Date: Fri, 14 Oct 2011 11:24:55 -0300 [thread overview]
Message-ID: <20111014112455.2d2d147b@doriath> (raw)
In-Reply-To: <4E983B19.90707@redhat.com>
On Fri, 14 Oct 2011 15:37:29 +0200
Paolo Bonzini <pbonzini@redhat.com> 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
next prev parent reply other threads:[~2011-10-14 14:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-04 13:10 [Qemu-devel] [PATCH] runstate: add more valid transitions Paolo Bonzini
2011-10-04 13:15 ` [Qemu-devel] [PATCH v2] " Paolo Bonzini
2011-10-10 18:50 ` Luiz Capitulino
2011-10-11 7:22 ` Paolo Bonzini
2011-10-11 17:52 ` Luiz Capitulino
2011-10-13 20:26 ` Luiz Capitulino
2011-10-14 6:56 ` Paolo Bonzini
2011-10-14 13:23 ` Luiz Capitulino
2011-10-14 13:37 ` Paolo Bonzini
2011-10-14 14:24 ` Luiz Capitulino [this message]
2011-10-14 14:26 ` Paolo Bonzini
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=20111014112455.2d2d147b@doriath \
--to=lcapitulino@redhat.com \
--cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).