Patchwork runstate: add more valid transitions

login
register
mail settings
Submitter Paolo Bonzini
Date Oct. 4, 2011, 1:10 p.m.
Message ID <1317733839-18143-1-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/117617/
State New
Headers show

Comments

Paolo Bonzini - Oct. 4, 2011, 1:10 p.m.
This patch adds more valid transitions to the table, and avoids
that the VM remains stuck in RSTATE_SAVEVM state when savevm is
done on a paused virtual machine.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 savevm.c |   11 ++++++++---
 vl.c     |    5 +++++
 2 files changed, 13 insertions(+), 3 deletions(-)

Patch

diff --git a/savevm.c b/savevm.c
index 46f2447..ba5beb0 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1599,7 +1599,7 @@  void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f)
 
 static int qemu_savevm_state(Monitor *mon, QEMUFile *f)
 {
-    int saved_vm_running;
+    int saved_vm_state;
     int ret;
 
     saved_vm_running = runstate_is_running();
@@ -1626,8 +1626,13 @@  out:
     if (qemu_file_has_error(f))
         ret = -EIO;
 
-    if (!ret && saved_vm_running)
-        vm_start();
+    if (!ret) {
+        if (saved_vm_running) {
+            vm_start();
+        } else {
+            runstate_set(RSTATE_PAUSED);
+        }
+    }
 
     return ret;
 }
diff --git a/vl.c b/vl.c
index bd4a5ce..165712e 100644
--- a/vl.c
+++ b/vl.c
@@ -346,8 +346,12 @@  static const RunStateTransition runstate_transitions_def[] = {
     { RSTATE_IO_ERROR, RSTATE_RUNNING },
 
     { RSTATE_PAUSED, RSTATE_RUNNING },
+    { RSTATE_PAUSED, RSTATE_PRE_MIGRATE },
+    { RSTATE_PAUSED, RSTATE_SAVEVM },
 
     { RSTATE_POST_MIGRATE, RSTATE_RUNNING },
+    { RSTATE_POST_MIGRATE, RSTATE_PRE_MIGRATE },
+    { RSTATE_POST_MIGRATE, RSTATE_SAVEVM },
 
     { RSTATE_PRE_LAUNCH, RSTATE_RUNNING },
     { RSTATE_PRE_LAUNCH, RSTATE_POST_MIGRATE },
@@ -368,6 +372,7 @@  static const RunStateTransition runstate_transitions_def[] = {
     { RSTATE_RUNNING, RSTATE_WATCHDOG },
 
     { RSTATE_SAVEVM, RSTATE_RUNNING },
+    { RSTATE_SAVEVM, RSTATE_PAUSED },
 
     { RSTATE_SHUTDOWN, RSTATE_PAUSED },