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 08/36] buffered_file: reuse QEMUFile has_error field
Date: Mon, 17 Oct 2011 08:57:02 -0500	[thread overview]
Message-ID: <4E9C342E.8010100@codemonkey.ws> (raw)
In-Reply-To: <bc630a6a14304db873115955a9897dcc1647f308.1318326683.git.quintela@redhat.com>

On 10/11/2011 05:00 AM, Juan Quintela wrote:
> Instead of having two has_error fields in QEMUFile&  QEMUBufferedFile,
> reuse the 1st one.  Notice that the one in buffered_file is only set
> after a file operation.
>
> Signed-off-by: Juan Quintela<quintela@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   buffered_file.c |   17 ++++++++---------
>   1 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/buffered_file.c b/buffered_file.c
> index 701b440..3dadec0 100644
> --- a/buffered_file.c
> +++ b/buffered_file.c
> @@ -27,7 +27,6 @@ typedef struct QEMUFileBuffered
>       BufferedCloseFunc *close;
>       void *opaque;
>       QEMUFile *file;
> -    int has_error;
>       int freeze_output;
>       size_t bytes_xfer;
>       size_t xfer_limit;
> @@ -73,7 +72,7 @@ static void buffered_flush(QEMUFileBuffered *s)
>   {
>       size_t offset = 0;
>
> -    if (s->has_error) {
> +    if (qemu_file_has_error(s->file)) {
>           DPRINTF("flush when error, bailing\n");
>           return;
>       }
> @@ -93,7 +92,7 @@ static void buffered_flush(QEMUFileBuffered *s)
>
>           if (ret<= 0) {
>               DPRINTF("error flushing data, %zd\n", ret);
> -            s->has_error = 1;
> +            qemu_file_set_error(s->file);
>               break;
>           } else {
>               DPRINTF("flushed %zd byte(s)\n", ret);
> @@ -114,7 +113,7 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in
>
>       DPRINTF("putting %d bytes at %" PRId64 "\n", size, pos);
>
> -    if (s->has_error) {
> +    if (qemu_file_has_error(s->file)) {
>           DPRINTF("flush when error, bailing\n");
>           return -EINVAL;
>       }
> @@ -139,7 +138,7 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in
>
>           if (ret<= 0) {
>               DPRINTF("error putting\n");
> -            s->has_error = 1;
> +            qemu_file_set_error(s->file);
>               offset = -EINVAL;
>               break;
>           }
> @@ -173,7 +172,7 @@ static int buffered_close(void *opaque)
>
>       DPRINTF("closing\n");
>
> -    while (!s->has_error&&  s->buffer_size) {
> +    while (!qemu_file_has_error(s->file)&&  s->buffer_size) {
>           buffered_flush(s);
>           if (s->freeze_output)
>               s->wait_for_unfreeze(s->opaque);
> @@ -193,7 +192,7 @@ static int buffered_rate_limit(void *opaque)
>   {
>       QEMUFileBuffered *s = opaque;
>
> -    if (s->has_error) {
> +    if (qemu_file_has_error(s->file)) {
>           return 1;
>       }
>       if (s->freeze_output)
> @@ -208,7 +207,7 @@ static int buffered_rate_limit(void *opaque)
>   static int64_t buffered_set_rate_limit(void *opaque, int64_t new_rate)
>   {
>       QEMUFileBuffered *s = opaque;
> -    if (s->has_error)
> +    if (qemu_file_has_error(s->file))
>           goto out;
>
>       if (new_rate>  SIZE_MAX) {
> @@ -232,7 +231,7 @@ static void buffered_rate_tick(void *opaque)
>   {
>       QEMUFileBuffered *s = opaque;
>
> -    if (s->has_error) {
> +    if (qemu_file_has_error(s->file)) {
>           buffered_close(s);
>           return;
>       }

  reply	other threads:[~2011-10-17 13:57 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-11 10:00 [Qemu-devel] [PATCH v4 00/36] Migration errors & cleanup (the integrated version) Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 01/36] ds1225y: Use stdio instead of QEMUFile Juan Quintela
2011-10-12  8:47   ` Zhi Hui Li
2011-10-17 13:50   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 02/36] migration: simplify state assignmente Juan Quintela
2011-10-17 13:52   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 03/36] migration: Check that migration is active before cancel it Juan Quintela
2011-10-17 13:53   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 04/36] migration: return real error code Juan Quintela
2011-10-17 13:53   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 05/36] migration: add error handling to migrate_fd_put_notify() Juan Quintela
2011-10-17 13:54   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 06/36] migration: If there is one error, it makes no sense to continue Juan Quintela
2011-10-17 13:56   ` Anthony Liguori
2011-10-17 16:58     ` Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 07/36] buffered_file: Use right "opaque" Juan Quintela
2011-10-17 13:56   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 08/36] buffered_file: reuse QEMUFile has_error field Juan Quintela
2011-10-17 13:57   ` Anthony Liguori [this message]
2011-10-11 10:00 ` [Qemu-devel] [PATCH 09/36] migration: don't "write" when migration is not active Juan Quintela
2011-10-17 13:59   ` Anthony Liguori
2011-10-17 17:04     ` Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 10/36] migration: set error if select return one error Juan Quintela
2011-10-17 13:59   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 11/36] migration: change has_error to contain errno values Juan Quintela
2011-10-17 14:00   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 12/36] migration: rename qemu_file_has_error to qemu_file_get_error Juan Quintela
2011-10-17 14:00   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 13/36] savevm: Rename has_error to last_error field Juan Quintela
2011-10-17 14:00   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 14/36] migration: use qemu_file_get_error() return value when possible Juan Quintela
2011-10-17 14:01   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 15/36] migration: Make *start_outgoing_migration return FdMigrationState Juan Quintela
2011-10-17 14:01   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 16/36] migration: Use FdMigrationState instead of MigrationState when possible Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 17/36] migration: Fold MigrationState into FdMigrationState Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 18/36] migration: Rename FdMigrationState MigrationState Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 19/36] migration: Refactor MigrationState creation Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 20/36] migration: Make all posible migration functions static Juan Quintela
2011-10-17 14:02   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 21/36] migration: move migrate_new to do_migrate Juan Quintela
2011-10-17 14:03   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 22/36] migration: Introduce MIG_STATE_SETUP Juan Quintela
2011-10-17 14:03   ` Anthony Liguori
2011-10-18  1:29     ` Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 23/36] migration: Refactor and simplify error checking in migrate_fd_put_ready Juan Quintela
2011-10-17 14:05   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 24/36] migration: Introduce migrate_fd_completed() for consistency Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 25/36] migration: Our release callback was just free Juan Quintela
2011-10-17 14:06   ` Anthony Liguori
2011-10-17 15:12     ` Juan Quintela
2011-10-17 15:20       ` Anthony Liguori
2011-10-17 15:18   ` Anthony Liguori
2011-10-11 10:00 ` [Qemu-devel] [PATCH 26/36] migration: Remove get_status() accessor Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 27/36] migration: Remove migration cancel() callback Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 28/36] migration: Move exported functions to the end of the file Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 29/36] migration: create accessor for current_migration Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 30/36] migration: Use bandwidth_limit directly Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 31/36] migration: Pass MigrationState in migration notifiers Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 32/36] migration: Export a function that tells if the migration has finished correctly Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 33/36] migration: Make state definitions local Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 34/36] migration: Don't use callback on file defining it Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 35/36] migration: propagate error correctly Juan Quintela
2011-10-11 10:00 ` [Qemu-devel] [PATCH 36/36] migration: make migration-{tcp, unix} consistent 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=4E9C342E.8010100@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).