Patchwork [17/27] buffered_file: unfold migrate_fd_put_buffer

login
register
mail settings
Submitter Juan Quintela
Date July 24, 2012, 6:36 p.m.
Message ID <1343155012-26316-18-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/173033/
State New
Headers show

Comments

Juan Quintela - July 24, 2012, 6:36 p.m.
We only used it once, just remove the callback indirection.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 buffered_file.c |    7 ++-----
 buffered_file.h |    5 +----
 migration.c     |    8 ++------
 migration.h     |    1 +
 4 files changed, 6 insertions(+), 15 deletions(-)

Patch

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

 typedef struct QEMUFileBuffered
 {
-    BufferedCloseFunc *close;
     MigrationState *migration_state;
     QEMUFile *file;
     int freeze_output;
@@ -147,7 +146,7 @@  static int buffered_close(void *opaque)
             migrate_fd_wait_for_unfreeze(s->migration_state);
     }

-    ret = s->close(s->migration_state);
+    ret = migrate_fd_close(s->migration_state);

     qemu_del_timer(s->timer);
     qemu_free_timer(s->timer);
@@ -224,8 +223,7 @@  static void buffered_rate_tick(void *opaque)
 }

 QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
-                                  size_t bytes_per_sec,
-                                  BufferedCloseFunc *close)
+                                  size_t bytes_per_sec)
 {
     QEMUFileBuffered *s;

@@ -233,7 +231,6 @@  QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,

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

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

-typedef int (BufferedCloseFunc)(void *opaque);
-
 QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
-                                  size_t xfer_limit,
-                                  BufferedCloseFunc *close);
+                                  size_t xfer_limit);

 #endif
diff --git a/migration.c b/migration.c
index 3561b16..c639c99 100644
--- a/migration.c
+++ b/migration.c
@@ -396,10 +396,8 @@  void migrate_fd_wait_for_unfreeze(MigrationState *s)
     }
 }

-static int migrate_fd_close(void *opaque)
+int migrate_fd_close(MigrationState *s)
 {
-    MigrationState *s = opaque;
-
     qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
     return s->close(s);
 }
@@ -435,9 +433,7 @@  void migrate_fd_connect(MigrationState *s)
     int ret;

     s->state = MIG_STATE_ACTIVE;
-    s->file = qemu_fopen_ops_buffered(s,
-                                      s->bandwidth_limit,
-                                      migrate_fd_close);
+    s->file = qemu_fopen_ops_buffered(s, s->bandwidth_limit);

     DPRINTF("beginning savevm\n");
     ret = qemu_savevm_state_begin(s->file, &s->params);
diff --git a/migration.h b/migration.h
index 62fc4f3..f3a684a 100644
--- a/migration.h
+++ b/migration.h
@@ -79,6 +79,7 @@  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_close(MigrationState *s);

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