[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions
From: |
Luiz Capitulino |
Subject: |
Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions |
Date: |
Fri, 14 Oct 2011 11:24:55 -0300 |
On Fri, 14 Oct 2011 15:37:29 +0200
Paolo Bonzini <address@hidden> 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
- [Qemu-devel] [PATCH] runstate: add more valid transitions, Paolo Bonzini, 2011/10/04
- [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Paolo Bonzini, 2011/10/04
- Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Luiz Capitulino, 2011/10/10
- [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Paolo Bonzini, 2011/10/11
- Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Luiz Capitulino, 2011/10/11
- Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Luiz Capitulino, 2011/10/13
- Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Paolo Bonzini, 2011/10/14
- Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Luiz Capitulino, 2011/10/14
- Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Paolo Bonzini, 2011/10/14
- Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions,
Luiz Capitulino <=
- Re: [Qemu-devel] [PATCH v2] runstate: add more valid transitions, Paolo Bonzini, 2011/10/14