qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 07/41] migration: use qemu_file_set_error to pas


From: Orit Wasserman
Subject: Re: [Qemu-devel] [PATCH 07/41] migration: use qemu_file_set_error to pass error codes back to qemu_savevm_state
Date: Mon, 18 Feb 2013 11:24:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 02/15/2013 07:46 PM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>  include/sysemu/sysemu.h |    6 +++---
>  savevm.c                |   44 ++++++++++++++++++--------------------------
>  2 files changed, 21 insertions(+), 29 deletions(-)
> 
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 1d9599e..28a9221 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -73,10 +73,10 @@ void do_info_snapshots(Monitor *mon, const QDict *qdict);
>  void qemu_announce_self(void);
>  
>  bool qemu_savevm_state_blocked(Error **errp);
> -int qemu_savevm_state_begin(QEMUFile *f,
> -                            const MigrationParams *params);
> +void qemu_savevm_state_begin(QEMUFile *f,
> +                             const MigrationParams *params);
>  int qemu_savevm_state_iterate(QEMUFile *f);
> -int qemu_savevm_state_complete(QEMUFile *f);
> +void qemu_savevm_state_complete(QEMUFile *f);
>  void qemu_savevm_state_cancel(void);
>  uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
>  int qemu_loadvm_state(QEMUFile *f);
> diff --git a/savevm.c b/savevm.c
> index a681177..a1690b4 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1579,8 +1579,8 @@ bool qemu_savevm_state_blocked(Error **errp)
>      return false;
>  }
>  
> -int qemu_savevm_state_begin(QEMUFile *f,
> -                            const MigrationParams *params)
> +void qemu_savevm_state_begin(QEMUFile *f,
> +                             const MigrationParams *params)
>  {
>      SaveStateEntry *se;
>      int ret;
> @@ -1620,11 +1620,10 @@ int qemu_savevm_state_begin(QEMUFile *f,
>  
>          ret = se->ops->save_live_setup(f, se->opaque);
>          if (ret < 0) {
> -            return ret;
> +            qemu_file_set_error(f, ret);
> +            break;
>          }
>      }
> -    ret = qemu_file_get_error(f);
> -    return ret;
>  }
>  
>  /*
> @@ -1658,6 +1657,9 @@ int qemu_savevm_state_iterate(QEMUFile *f)
>          ret = se->ops->save_live_iterate(f, se->opaque);
>          trace_savevm_section_end(se->section_id);
>  
> +        if (ret < 0) {
> +            qemu_file_set_error(f, ret);
> +        }
>          if (ret <= 0) {
>              /* Do not proceed to the next vmstate before this one reported
>                 completion of the current stage. This serializes the migration
> @@ -1666,14 +1668,10 @@ int qemu_savevm_state_iterate(QEMUFile *f)
>              break;
>          }
>      }
> -    if (ret != 0) {
> -        return ret;
> -    }
> -    ret = qemu_file_get_error(f);
>      return ret;
>  }
>  
> -int qemu_savevm_state_complete(QEMUFile *f)
> +void qemu_savevm_state_complete(QEMUFile *f)
>  {
>      SaveStateEntry *se;
>      int ret;
> @@ -1697,7 +1695,8 @@ int qemu_savevm_state_complete(QEMUFile *f)
>          ret = se->ops->save_live_complete(f, se->opaque);
>          trace_savevm_section_end(se->section_id);
>          if (ret < 0) {
> -            return ret;
> +            qemu_file_set_error(f, ret);
> +            return;
>          }
>      }
>  
> @@ -1725,8 +1724,6 @@ int qemu_savevm_state_complete(QEMUFile *f)
>      }
>  
>      qemu_put_byte(f, QEMU_VM_EOF);
> -
> -    return qemu_file_get_error(f);
>  }
>  
>  uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size)
> @@ -1771,26 +1768,21 @@ static int qemu_savevm_state(QEMUFile *f)
>          return -EINVAL;
>      }
>  
> -    ret = qemu_savevm_state_begin(f, &params);
> -    if (ret < 0)
> -        goto out;
> -
> -    do {
> -        ret = qemu_savevm_state_iterate(f);
> -        if (ret < 0)
> -            goto out;
> -    } while (ret == 0);
> -
> -    ret = qemu_savevm_state_complete(f);
> +    qemu_savevm_state_begin(f, &params);
> +    while (qemu_file_get_error(f) == 0) {
> +        if (qemu_savevm_state_iterate(f) > 0) {
> +            break;
> +        }
> +    }
>  
> -out:
> +    ret = qemu_file_get_error(f);
>      if (ret == 0) {
> +        qemu_savevm_state_complete(f);
>          ret = qemu_file_get_error(f);
>      }
>      if (ret != 0) {
>          qemu_savevm_state_cancel();
>      }
> -
>      return ret;
>  }
>  
> 
Reviewed-by: Orit Wasserman <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]