Patchwork [39/41] migration: move contents of migration_close to migrate_fd_cleanup

login
register
mail settings
Submitter Paolo Bonzini
Date Feb. 15, 2013, 5:47 p.m.
Message ID <1360950433-17106-40-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/220802/
State New
Headers show

Comments

Paolo Bonzini - Feb. 15, 2013, 5:47 p.m.
With this patch, the migration_file is not needed anymore.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 migration.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
Juan Quintela - Feb. 22, 2013, 11:44 a.m.
Paolo Bonzini <pbonzini@redhat.com> wrote:
> With this patch, the migration_file is not needed anymore.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>
Orit Wasserman - Feb. 22, 2013, 1:56 p.m.
On 02/15/2013 07:47 PM, Paolo Bonzini wrote:
> With this patch, the migration_file is not needed anymore.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  migration.c |   17 +++++++----------
>  1 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 7c1671f..c9a5978 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -271,6 +271,12 @@ static void migrate_fd_cleanup(void *opaque)
>          DPRINTF("closing file\n");
>          qemu_fclose(s->file);
>          s->file = NULL;
> +
> +        qemu_mutex_unlock_iothread();
> +        qemu_thread_join(&s->thread);
> +        qemu_mutex_lock_iothread();
> +
> +        migrate_fd_close(s);
>      }
>  
>      assert(s->migration_file == NULL);
> @@ -506,16 +512,7 @@ static int migration_put_buffer(void *opaque, const uint8_t *buf,
>  
>  static int migration_close(void *opaque)
>  {
> -    MigrationState *s = opaque;
> -
> -    DPRINTF("closing\n");
> -
> -    qemu_mutex_unlock_iothread();
> -    qemu_thread_join(&s->thread);
> -    qemu_mutex_lock_iothread();
> -    assert (s->state != MIG_STATE_ACTIVE);
> -
> -    return migrate_fd_close(s);
> +    return 0;
>  }
>  
>  static int migration_get_fd(void *opaque)
> 
Reviewed-by: Orit Wasserman <owasserm@redhat.com>

Patch

diff --git a/migration.c b/migration.c
index 7c1671f..c9a5978 100644
--- a/migration.c
+++ b/migration.c
@@ -271,6 +271,12 @@  static void migrate_fd_cleanup(void *opaque)
         DPRINTF("closing file\n");
         qemu_fclose(s->file);
         s->file = NULL;
+
+        qemu_mutex_unlock_iothread();
+        qemu_thread_join(&s->thread);
+        qemu_mutex_lock_iothread();
+
+        migrate_fd_close(s);
     }
 
     assert(s->migration_file == NULL);
@@ -506,16 +512,7 @@  static int migration_put_buffer(void *opaque, const uint8_t *buf,
 
 static int migration_close(void *opaque)
 {
-    MigrationState *s = opaque;
-
-    DPRINTF("closing\n");
-
-    qemu_mutex_unlock_iothread();
-    qemu_thread_join(&s->thread);
-    qemu_mutex_lock_iothread();
-    assert (s->state != MIG_STATE_ACTIVE);
-
-    return migrate_fd_close(s);
+    return 0;
 }
 
 static int migration_get_fd(void *opaque)