Patchwork [21/41] buffered_file: unfold migrate_fd_put_buffer

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

Comments

Juan Quintela - Sept. 21, 2012, 8:47 a.m.
We only used it once, just remove the callback indirection.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 buffered_file.c | 5 +----
 buffered_file.h | 2 --
 migration.c     | 4 +---
 migration.h     | 1 +
 4 files changed, 3 insertions(+), 9 deletions(-)
Paolo Bonzini - Sept. 21, 2012, 12:34 p.m.
Il 21/09/2012 10:47, Juan Quintela ha scritto:
> We only used it once, just remove the callback indirection.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  buffered_file.c | 5 +----
>  buffered_file.h | 2 --
>  migration.c     | 4 +---
>  migration.h     | 1 +
>  4 files changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/buffered_file.c b/buffered_file.c
> index 4c6a797..d257496 100644
> --- a/buffered_file.c
> +++ b/buffered_file.c
> @@ -23,7 +23,6 @@
> 
>  typedef struct QEMUFileBuffered
>  {
> -    BufferedWaitForUnfreezeFunc *wait_for_unfreeze;

Should be "buffered_file: unfold migrate_fd_wait_for_unfreeze".
Otherwise looks good.

I misaddressed some answers just to Juan, omitting qemu-devel.  All
patches I haven't replied to publicly, up to this one, are Reviewed-by me.

Paolo

>      BufferedCloseFunc *close;
>      MigrationState *migration_state;
>      QEMUFile *file;
> @@ -145,7 +144,7 @@ static int buffered_close(void *opaque)
>      while (!qemu_file_get_error(s->file) && s->buffer_size) {
>          buffered_flush(s);
>          if (s->freeze_output)
> -            s->wait_for_unfreeze(s->migration_state);
> +            migrate_fd_wait_for_unfreeze(s->migration_state);
>      }
> 
>      ret = s->close(s->migration_state);
> @@ -226,7 +225,6 @@ static void buffered_rate_tick(void *opaque)
> 
>  QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
>                                    size_t bytes_per_sec,
> -                                  BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
>                                    BufferedCloseFunc *close)
>  {
>      QEMUFileBuffered *s;
> @@ -235,7 +233,6 @@ QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
> 
>      s->migration_state = migration_state;
>      s->xfer_limit = bytes_per_sec / 10;
> -    s->wait_for_unfreeze = wait_for_unfreeze;
>      s->close = close;
> 
>      s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
> diff --git a/buffered_file.h b/buffered_file.h
> index dd239b3..926e5c6 100644
> --- a/buffered_file.h
> +++ b/buffered_file.h
> @@ -17,12 +17,10 @@
>  #include "hw/hw.h"
>  #include "migration.h"
> 
> -typedef void (BufferedWaitForUnfreezeFunc)(void *opaque);
>  typedef int (BufferedCloseFunc)(void *opaque);
> 
>  QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
>                                    size_t xfer_limit,
> -                                  BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
>                                    BufferedCloseFunc *close);
> 
>  #endif
> diff --git a/migration.c b/migration.c
> index d0d1014..add4632 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -368,9 +368,8 @@ static void migrate_fd_cancel(MigrationState *s)
>      migrate_fd_cleanup(s);
>  }
> 
> -static void migrate_fd_wait_for_unfreeze(void *opaque)
> +void migrate_fd_wait_for_unfreeze(MigrationState *s)
>  {
> -    MigrationState *s = opaque;
>      int ret;
> 
>      DPRINTF("wait for unfreeze\n");
> @@ -432,7 +431,6 @@ void migrate_fd_connect(MigrationState *s)
>      s->state = MIG_STATE_ACTIVE;
>      s->file = qemu_fopen_ops_buffered(s,
>                                        s->bandwidth_limit,
> -                                      migrate_fd_wait_for_unfreeze,
>                                        migrate_fd_close);
> 
>      DPRINTF("beginning savevm\n");
> diff --git a/migration.h b/migration.h
> index 031c2ab..d6341d6 100644
> --- a/migration.h
> +++ b/migration.h
> @@ -81,6 +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);
> 
>  void add_migration_state_change_notifier(Notifier *notify);
>  void remove_migration_state_change_notifier(Notifier *notify);
>

Patch

diff --git a/buffered_file.c b/buffered_file.c
index 4c6a797..d257496 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -23,7 +23,6 @@ 

 typedef struct QEMUFileBuffered
 {
-    BufferedWaitForUnfreezeFunc *wait_for_unfreeze;
     BufferedCloseFunc *close;
     MigrationState *migration_state;
     QEMUFile *file;
@@ -145,7 +144,7 @@  static int buffered_close(void *opaque)
     while (!qemu_file_get_error(s->file) && s->buffer_size) {
         buffered_flush(s);
         if (s->freeze_output)
-            s->wait_for_unfreeze(s->migration_state);
+            migrate_fd_wait_for_unfreeze(s->migration_state);
     }

     ret = s->close(s->migration_state);
@@ -226,7 +225,6 @@  static void buffered_rate_tick(void *opaque)

 QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
                                   size_t bytes_per_sec,
-                                  BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
                                   BufferedCloseFunc *close)
 {
     QEMUFileBuffered *s;
@@ -235,7 +233,6 @@  QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,

     s->migration_state = migration_state;
     s->xfer_limit = bytes_per_sec / 10;
-    s->wait_for_unfreeze = wait_for_unfreeze;
     s->close = close;

     s->file = qemu_fopen_ops(s, buffered_put_buffer, NULL,
diff --git a/buffered_file.h b/buffered_file.h
index dd239b3..926e5c6 100644
--- a/buffered_file.h
+++ b/buffered_file.h
@@ -17,12 +17,10 @@ 
 #include "hw/hw.h"
 #include "migration.h"

-typedef void (BufferedWaitForUnfreezeFunc)(void *opaque);
 typedef int (BufferedCloseFunc)(void *opaque);

 QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
                                   size_t xfer_limit,
-                                  BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
                                   BufferedCloseFunc *close);

 #endif
diff --git a/migration.c b/migration.c
index d0d1014..add4632 100644
--- a/migration.c
+++ b/migration.c
@@ -368,9 +368,8 @@  static void migrate_fd_cancel(MigrationState *s)
     migrate_fd_cleanup(s);
 }

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

     DPRINTF("wait for unfreeze\n");
@@ -432,7 +431,6 @@  void migrate_fd_connect(MigrationState *s)
     s->state = MIG_STATE_ACTIVE;
     s->file = qemu_fopen_ops_buffered(s,
                                       s->bandwidth_limit,
-                                      migrate_fd_wait_for_unfreeze,
                                       migrate_fd_close);

     DPRINTF("beginning savevm\n");
diff --git a/migration.h b/migration.h
index 031c2ab..d6341d6 100644
--- a/migration.h
+++ b/migration.h
@@ -81,6 +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);

 void add_migration_state_change_notifier(Notifier *notify);
 void remove_migration_state_change_notifier(Notifier *notify);