Patchwork [18/41] buffered_file: opaque is MigrationState

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

Comments

Juan Quintela - Sept. 21, 2012, 8:47 a.m.
It always have that type, just change it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 buffered_file.c | 6 +++---
 buffered_file.h | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)
Orit Wasserman - Sept. 25, 2012, 11:46 a.m.
On 09/21/2012 11:47 AM, Juan Quintela wrote:
> It always have that type, just change it.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  buffered_file.c | 6 +++---
>  buffered_file.h | 4 +++-
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/buffered_file.c b/buffered_file.c
> index 33b700b..59d952d 100644
> --- a/buffered_file.c
> +++ b/buffered_file.c
> @@ -27,7 +27,7 @@ typedef struct QEMUFileBuffered
>      BufferedPutReadyFunc *put_ready;
>      BufferedWaitForUnfreezeFunc *wait_for_unfreeze;
>      BufferedCloseFunc *close;
> -    void *migration_state;
> +    MigrationState *migration_state;
>      QEMUFile *file;
>      int freeze_output;
>      size_t bytes_xfer;
> @@ -226,7 +226,7 @@ static void buffered_rate_tick(void *opaque)
>      buffered_put_buffer(s, NULL, 0, 0);
>  }
> 
> -QEMUFile *qemu_fopen_ops_buffered(void *opaque,
> +QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
>                                    size_t bytes_per_sec,
>                                    BufferedPutFunc *put_buffer,
>                                    BufferedPutReadyFunc *put_ready,
> @@ -237,7 +237,7 @@ QEMUFile *qemu_fopen_ops_buffered(void *opaque,
> 
>      s = g_malloc0(sizeof(*s));
> 
> -    s->migration_state = opaque;
> +    s->migration_state = migration_state;
>      s->xfer_limit = bytes_per_sec / 10;
>      s->put_buffer = put_buffer;
>      s->put_ready = put_ready;
> diff --git a/buffered_file.h b/buffered_file.h
> index 98d358b..39f7fa0 100644
> --- a/buffered_file.h
> +++ b/buffered_file.h
> @@ -15,13 +15,15 @@
>  #define QEMU_BUFFERED_FILE_H
> 
>  #include "hw/hw.h"
> +#include "migration.h"
> 
>  typedef ssize_t (BufferedPutFunc)(void *opaque, const void *data, size_t size);
>  typedef void (BufferedPutReadyFunc)(void *opaque);
>  typedef void (BufferedWaitForUnfreezeFunc)(void *opaque);
>  typedef int (BufferedCloseFunc)(void *opaque);
> 
> -QEMUFile *qemu_fopen_ops_buffered(void *opaque, size_t xfer_limit,
> +QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
> +                                  size_t xfer_limit,
>                                    BufferedPutFunc *put_buffer,
>                                    BufferedPutReadyFunc *put_ready,
>                                    BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
> 
Again why ? this is a general buffered file not just for migration use.

Orit
Juan Quintela - Sept. 28, 2012, 7:33 a.m.
Orit Wasserman <owasserm@redhat.com> wrote:
> On 09/21/2012 11:47 AM, Juan Quintela wrote:
>> It always have that type, just change it.
>> -QEMUFile *qemu_fopen_ops_buffered(void *opaque, size_t xfer_limit,
>> +QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
>> +                                  size_t xfer_limit,
>>                                    BufferedPutFunc *put_buffer,
>>                                    BufferedPutReadyFunc *put_ready,
>>                                    BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
>> 
> Again why ? this is a general buffered file not just for migration use.

It is not used for anything else.  It is used only, and inlining it
removes one level of indirection.  All wins on my book.

Notice that once the migration-thread patches end, this file basically
dissapears (its only reason to exist was to allow non-blocking writes").

Later, Juan.
Orit Wasserman - Sept. 28, 2012, 7:48 a.m.
On 09/28/2012 09:33 AM, Juan Quintela wrote:
> Orit Wasserman <owasserm@redhat.com> wrote:
>> On 09/21/2012 11:47 AM, Juan Quintela wrote:
>>> It always have that type, just change it.
>>> -QEMUFile *qemu_fopen_ops_buffered(void *opaque, size_t xfer_limit,
>>> +QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
>>> +                                  size_t xfer_limit,
>>>                                    BufferedPutFunc *put_buffer,
>>>                                    BufferedPutReadyFunc *put_ready,
>>>                                    BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
>>>
>> Again why ? this is a general buffered file not just for migration use.
> 
> It is not used for anything else.  It is used only, and inlining it
> removes one level of indirection.  All wins on my book.
> 
> Notice that once the migration-thread patches end, this file basically
> dissapears (its only reason to exist was to allow non-blocking writes").
> 
yes I read the second series and get it now (maybe more details in the commit comment can help).

Cheers,
Orit
> Later, Juan.
>

Patch

diff --git a/buffered_file.c b/buffered_file.c
index 33b700b..59d952d 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -27,7 +27,7 @@  typedef struct QEMUFileBuffered
     BufferedPutReadyFunc *put_ready;
     BufferedWaitForUnfreezeFunc *wait_for_unfreeze;
     BufferedCloseFunc *close;
-    void *migration_state;
+    MigrationState *migration_state;
     QEMUFile *file;
     int freeze_output;
     size_t bytes_xfer;
@@ -226,7 +226,7 @@  static void buffered_rate_tick(void *opaque)
     buffered_put_buffer(s, NULL, 0, 0);
 }

-QEMUFile *qemu_fopen_ops_buffered(void *opaque,
+QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
                                   size_t bytes_per_sec,
                                   BufferedPutFunc *put_buffer,
                                   BufferedPutReadyFunc *put_ready,
@@ -237,7 +237,7 @@  QEMUFile *qemu_fopen_ops_buffered(void *opaque,

     s = g_malloc0(sizeof(*s));

-    s->migration_state = opaque;
+    s->migration_state = migration_state;
     s->xfer_limit = bytes_per_sec / 10;
     s->put_buffer = put_buffer;
     s->put_ready = put_ready;
diff --git a/buffered_file.h b/buffered_file.h
index 98d358b..39f7fa0 100644
--- a/buffered_file.h
+++ b/buffered_file.h
@@ -15,13 +15,15 @@ 
 #define QEMU_BUFFERED_FILE_H

 #include "hw/hw.h"
+#include "migration.h"

 typedef ssize_t (BufferedPutFunc)(void *opaque, const void *data, size_t size);
 typedef void (BufferedPutReadyFunc)(void *opaque);
 typedef void (BufferedWaitForUnfreezeFunc)(void *opaque);
 typedef int (BufferedCloseFunc)(void *opaque);

-QEMUFile *qemu_fopen_ops_buffered(void *opaque, size_t xfer_limit,
+QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state,
+                                  size_t xfer_limit,
                                   BufferedPutFunc *put_buffer,
                                   BufferedPutReadyFunc *put_ready,
                                   BufferedWaitForUnfreezeFunc *wait_for_unfreeze,