Patchwork [v2] runstate: add more valid transitions

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

Comments

Paolo Bonzini - Oct. 4, 2011, 1:15 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 |    9 +++++++--
 vl.c     |    5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)
Luiz Capitulino - Oct. 10, 2011, 6:50 p.m.
On Tue,  4 Oct 2011 15:15:40 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:

> 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>

Looks good, but it needs to be rebased against latest master.

> ---
>  savevm.c |    9 +++++++--
>  vl.c     |    5 +++++
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/savevm.c b/savevm.c
> index 46f2447..ff37968 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -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 },
>

Patch

diff --git a/savevm.c b/savevm.c
index 46f2447..ff37968 100644
--- a/savevm.c
+++ b/savevm.c
@@ -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 },