qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 04/11] migration: return real error code
Date: Tue, 04 Oct 2011 13:08:02 -0500	[thread overview]
Message-ID: <4E8B4B82.4080107@codemonkey.ws> (raw)
In-Reply-To: <5529f9bd516a73e64eb7f9761e85cd2240030dfd.1316781876.git.quintela@redhat.com>

On 09/23/2011 07:50 AM, Juan Quintela wrote:
> make functions propaget errno, instead of just using -EIO.
>
> Signed-off-by: Juan Quintela<quintela@redhat.com>

qemu_file_has_error() implies a boolean response.  Wouldn't 
qemu_file_get_error() make more sense if you're going to rely on the return value?

Regards,

Anthony Liguori

> ---
>   migration.c |    6 +++++-
>   savevm.c    |   33 +++++++++++++++------------------
>   2 files changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/migration.c b/migration.c
> index ea7bcc8..9498e20 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -363,6 +363,7 @@ void migrate_fd_connect(FdMigrationState *s)
>   void migrate_fd_put_ready(void *opaque)
>   {
>       FdMigrationState *s = opaque;
> +    int ret;
>
>       if (s->state != MIG_STATE_ACTIVE) {
>           DPRINTF("put_ready returning because of non-active state\n");
> @@ -370,7 +371,10 @@ void migrate_fd_put_ready(void *opaque)
>       }
>
>       DPRINTF("iterate\n");
> -    if (qemu_savevm_state_iterate(s->mon, s->file) == 1) {
> +    ret = qemu_savevm_state_iterate(s->mon, s->file);
> +    if (ret<  0) {
> +        migrate_fd_error(s);
> +    } else if (ret == 1) {
>           int old_vm_running = runstate_is_running();
>
>           DPRINTF("done iterating\n");
> diff --git a/savevm.c b/savevm.c
> index 46f2447..c382076 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1466,6 +1466,7 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
>                               int shared)
>   {
>       SaveStateEntry *se;
> +    int ret;
>
>       QTAILQ_FOREACH(se,&savevm_handlers, entry) {
>           if(se->set_params == NULL) {
> @@ -1497,13 +1498,13 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
>
>           se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque);
>       }
> -
> -    if (qemu_file_has_error(f)) {
> +    ret = qemu_file_has_error(f);
> +    if (ret != 0) {
>           qemu_savevm_state_cancel(mon, f);
> -        return -EIO;
>       }
>
> -    return 0;
> +    return ret;
> +
>   }
>
>   int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f)
> @@ -1528,16 +1529,14 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f)
>               break;
>           }
>       }
> -
> -    if (ret)
> -        return 1;
> -
> -    if (qemu_file_has_error(f)) {
> +    if (ret != 0) {
> +        return ret;
> +    }
> +    ret = qemu_file_has_error(f);
> +    if (ret != 0) {
>           qemu_savevm_state_cancel(mon, f);
> -        return -EIO;
>       }
> -
> -    return 0;
> +    return ret;
>   }
>
>   int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
> @@ -1580,10 +1579,7 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f)
>
>       qemu_put_byte(f, QEMU_VM_EOF);
>
> -    if (qemu_file_has_error(f))
> -        return -EIO;
> -
> -    return 0;
> +    return qemu_file_has_error(f);
>   }
>
>   void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f)
> @@ -1623,8 +1619,9 @@ static int qemu_savevm_state(Monitor *mon, QEMUFile *f)
>       ret = qemu_savevm_state_complete(mon, f);
>
>   out:
> -    if (qemu_file_has_error(f))
> -        ret = -EIO;
> +    if (ret == 0) {
> +        ret = qemu_file_has_error(f);
> +    }
>
>       if (!ret&&  saved_vm_running)
>           vm_start();

  reply	other threads:[~2011-10-04 18:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-23 12:50 [Qemu-devel] [PATCH v2 00/11] Handle errors during migration Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 01/11] ds1225y: Use stdio instead of QEMUFile Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 02/11] migration: simplify state assignmente Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 03/11] migration: Check that migration is active before cancel it Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 04/11] migration: return real error code Juan Quintela
2011-10-04 18:08   ` Anthony Liguori [this message]
2011-10-04 18:35     ` Juan Quintela
2011-10-05 19:52       ` Anthony Liguori
2011-10-05 20:07         ` Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 05/11] migration: add error handling to migrate_fd_put_notify() Juan Quintela
2011-09-23 13:45   ` Paolo Bonzini
2011-10-04 20:48     ` Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 06/11] migration: If there is one error, it makes no sense to continue Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 07/11] buffered_file: Use right "opaque" Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 08/11] buffered_file: reuse QEMUFile has_error field Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 09/11] migration: don't "write" when migration is not active Juan Quintela
2011-09-23 13:46   ` Paolo Bonzini
2011-09-23 12:50 ` [Qemu-devel] [PATCH 10/11] migration: set error if select return one error Juan Quintela
2011-09-23 12:50 ` [Qemu-devel] [PATCH 11/11] migration: change has_error to contain errno values Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E8B4B82.4080107@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).