Patchwork [7/7] migration: qemu_savevm_iterate has three return values

login
register
mail settings
Submitter Juan Quintela
Date Sept. 20, 2011, 1:24 p.m.
Message ID <c85dcdeabcd873d3cec69321b34d8ed189550958.1316524908.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/115540/
State New
Headers show

Comments

Juan Quintela - Sept. 20, 2011, 1:24 p.m.
We were retrying when there was one error, entering a loop.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Wayne Xia - Sept. 22, 2011, 9:50 a.m.
于 2011-9-20 21:24, Juan Quintela 写道:
> We were retrying when there was one error, entering a loop.
> 
> Signed-off-by: Juan Quintela<quintela@redhat.com>
> ---
>   migration.c |    6 +++++-
>   1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 7f8928a..0baed23 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -362,6 +362,7 @@ void migrate_fd_connect(FdMigrationState *s)
>   void migrate_fd_put_ready(void *opaque)
>   {
>       FdMigrationState *s = opaque;
> +    int ret;
> 
>       if (s->state != MIG_STATE_ACTIVE) {
>           DPRINTF("put_ready returning because of non-active state\n");
> @@ -369,7 +370,10 @@ void migrate_fd_put_ready(void *opaque)
>       }
> 
>       DPRINTF("iterate\n");
> -    if (qemu_savevm_state_iterate(s->mon, s->file) == 1) {
> +    ret = qemu_savevm_state_iterate(s->mon, s->file);
> +    if (ret == -1) {
> +        migrate_fd_error(s);
> +    } else if (ret == 1) {
>           int old_vm_running = vm_running;
> 
>           DPRINTF("done iterating\n");
Maybe macro could be used in the situation that more than 2 possible
types of value may return.

Patch

diff --git a/migration.c b/migration.c
index 7f8928a..0baed23 100644
--- a/migration.c
+++ b/migration.c
@@ -362,6 +362,7 @@  void migrate_fd_connect(FdMigrationState *s)
 void migrate_fd_put_ready(void *opaque)
 {
     FdMigrationState *s = opaque;
+    int ret;

     if (s->state != MIG_STATE_ACTIVE) {
         DPRINTF("put_ready returning because of non-active state\n");
@@ -369,7 +370,10 @@  void migrate_fd_put_ready(void *opaque)
     }

     DPRINTF("iterate\n");
-    if (qemu_savevm_state_iterate(s->mon, s->file) == 1) {
+    ret = qemu_savevm_state_iterate(s->mon, s->file);
+    if (ret == -1) {
+        migrate_fd_error(s);
+    } else if (ret == 1) {
         int old_vm_running = vm_running;

         DPRINTF("done iterating\n");