Patchwork [26/41] migration: make migrate_fd_wait_for_unfreeze() return errors

login
register
mail settings
Submitter Juan Quintela
Date Sept. 21, 2012, 8:47 a.m.
Message ID <1348217255-22441-27-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/185621/
State New
Headers show

Comments

Juan Quintela - Sept. 21, 2012, 8:47 a.m.
Adjust all callers

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 buffered_file.c | 8 ++++++--
 migration.c     | 7 ++++---
 migration.h     | 2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)
Paolo Bonzini - Sept. 21, 2012, 12:44 p.m.
Il 21/09/2012 10:47, Juan Quintela ha scritto:
> Adjust all callers
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  buffered_file.c | 8 ++++++--
>  migration.c     | 7 ++++---
>  migration.h     | 2 +-
>  3 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/buffered_file.c b/buffered_file.c
> index 9db73dc..6d9a50b 100644
> --- a/buffered_file.c
> +++ b/buffered_file.c
> @@ -149,8 +149,12 @@ static int buffered_close(void *opaque)
>          if (ret < 0) {
>              break;
>          }
> -        if (s->freeze_output)
> -            migrate_fd_wait_for_unfreeze(s->migration_state);
> +        if (s->freeze_output) {
> +            ret = migrate_fd_wait_for_unfreeze(s->migration_state);
> +            if (ret < 0) {
> +                break;
> +            }
> +        }
>      }
> 
>      ret2 = migrate_fd_close(s->migration_state);
> diff --git a/migration.c b/migration.c
> index 56014dd..6a505c1 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -368,13 +368,13 @@ static void migrate_fd_cancel(MigrationState *s)
>      migrate_fd_cleanup(s);
>  }
> 
> -void migrate_fd_wait_for_unfreeze(MigrationState *s)
> +int migrate_fd_wait_for_unfreeze(MigrationState *s)
>  {
>      int ret;
> 
>      DPRINTF("wait for unfreeze\n");
>      if (s->state != MIG_STATE_ACTIVE)
> -        return;
> +        return -EINVAL;
> 
>      do {
>          fd_set wfds;
> @@ -386,8 +386,9 @@ void migrate_fd_wait_for_unfreeze(MigrationState *s)
>      } while (ret == -1 && (s->get_error(s)) == EINTR);
> 
>      if (ret == -1) {
> -        qemu_file_set_error(s->file, -s->get_error(s));
> +        return -s->get_error(s);
>      }
> +    return 0;
>  }
> 
>  int migrate_fd_close(MigrationState *s)
> diff --git a/migration.h b/migration.h
> index ec022d6..1c3e9b7 100644
> --- a/migration.h
> +++ b/migration.h
> @@ -81,7 +81,7 @@ void migrate_fd_connect(MigrationState *s);
>  ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data,
>                                size_t size);
>  void migrate_fd_put_ready(MigrationState *s);
> -void migrate_fd_wait_for_unfreeze(MigrationState *s);
> +int migrate_fd_wait_for_unfreeze(MigrationState *s);
>  int migrate_fd_close(MigrationState *s);
> 
>  void add_migration_state_change_notifier(Notifier *notify);
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Patch

diff --git a/buffered_file.c b/buffered_file.c
index 9db73dc..6d9a50b 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -149,8 +149,12 @@  static int buffered_close(void *opaque)
         if (ret < 0) {
             break;
         }
-        if (s->freeze_output)
-            migrate_fd_wait_for_unfreeze(s->migration_state);
+        if (s->freeze_output) {
+            ret = migrate_fd_wait_for_unfreeze(s->migration_state);
+            if (ret < 0) {
+                break;
+            }
+        }
     }

     ret2 = migrate_fd_close(s->migration_state);
diff --git a/migration.c b/migration.c
index 56014dd..6a505c1 100644
--- a/migration.c
+++ b/migration.c
@@ -368,13 +368,13 @@  static void migrate_fd_cancel(MigrationState *s)
     migrate_fd_cleanup(s);
 }

-void migrate_fd_wait_for_unfreeze(MigrationState *s)
+int migrate_fd_wait_for_unfreeze(MigrationState *s)
 {
     int ret;

     DPRINTF("wait for unfreeze\n");
     if (s->state != MIG_STATE_ACTIVE)
-        return;
+        return -EINVAL;

     do {
         fd_set wfds;
@@ -386,8 +386,9 @@  void migrate_fd_wait_for_unfreeze(MigrationState *s)
     } while (ret == -1 && (s->get_error(s)) == EINTR);

     if (ret == -1) {
-        qemu_file_set_error(s->file, -s->get_error(s));
+        return -s->get_error(s);
     }
+    return 0;
 }

 int migrate_fd_close(MigrationState *s)
diff --git a/migration.h b/migration.h
index ec022d6..1c3e9b7 100644
--- a/migration.h
+++ b/migration.h
@@ -81,7 +81,7 @@  void migrate_fd_connect(MigrationState *s);
 ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data,
                               size_t size);
 void migrate_fd_put_ready(MigrationState *s);
-void migrate_fd_wait_for_unfreeze(MigrationState *s);
+int migrate_fd_wait_for_unfreeze(MigrationState *s);
 int migrate_fd_close(MigrationState *s);

 void add_migration_state_change_notifier(Notifier *notify);