On 02/15/2013 07:46 PM, Paolo Bonzini wrote:
> Right now, migration cannot entirely rely on QEMUFile's automatic
> drop of I/O after an error, because it does its "real" I/O outside
> the put_buffer callback.  To fix this until buffering is gone, expose
> qemu_file_set_error which we will use in buffered_flush.
> 
> Similarly, buffered_flush is not a complete flush because some data may
> still reside in the QEMUFile's own buffer.  This somewhat complicates the
> process of closing the migration thread.  Again, when buffering is gone
> buffered_flush will disappear and calling qemu_fflush will not be needed;
> in the meanwhile, we expose the function for use in migration.c.
> 
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
> ---
>  include/migration/qemu-file.h |    2 ++
>  savevm.c                      |    4 ++--
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
> index 46fc11d..5e0c287 100644
> --- a/include/migration/qemu-file.h
> +++ b/include/migration/qemu-file.h
> @@ -82,6 +82,7 @@ QEMUFile *qemu_popen_cmd(const char *command, const char 
> *mode);
>  int qemu_get_fd(QEMUFile *f);
>  int qemu_fclose(QEMUFile *f);
>  int64_t qemu_ftell(QEMUFile *f);
> +void qemu_fflush(QEMUFile *f);
>  void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
>  void qemu_put_byte(QEMUFile *f, int v);
>  
> @@ -113,6 +114,7 @@ int qemu_file_rate_limit(QEMUFile *f);
>  int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate);
>  int64_t qemu_file_get_rate_limit(QEMUFile *f);
>  int qemu_file_get_error(QEMUFile *f);
> +void qemu_file_set_error(QEMUFile *f, int ret);
>  
>  static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
>  {
> diff --git a/savevm.c b/savevm.c
> index a1690b4..e10a045 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -443,7 +443,7 @@ int qemu_file_get_error(QEMUFile *f)
>      return f->last_error;
>  }
>  
> -static void qemu_file_set_error(QEMUFile *f, int ret)
> +void qemu_file_set_error(QEMUFile *f, int ret)
>  {
>      if (f->last_error == 0) {
>          f->last_error = ret;
> @@ -453,7 +453,7 @@ static void qemu_file_set_error(QEMUFile *f, int ret)
>  /** Flushes QEMUFile buffer
>   *
>   */
> -static void qemu_fflush(QEMUFile *f)
> +void qemu_fflush(QEMUFile *f)
>  {
>      int ret = 0;
>  
> 
Reviewed-by: Orit Wasserman <owass...@redhat.com>

Reply via email to