@@ -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;
@@ -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) {
@@ -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);
@@ -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 },