From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TF2jj-0003LE-QN for qemu-devel@nongnu.org; Fri, 21 Sep 2012 08:53:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TF2jf-0004Ys-8h for qemu-devel@nongnu.org; Fri, 21 Sep 2012 08:53:39 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:34861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TF2jf-0004YR-3K for qemu-devel@nongnu.org; Fri, 21 Sep 2012 08:53:35 -0400 Received: by pbbrp12 with SMTP id rp12so7619915pbb.4 for ; Fri, 21 Sep 2012 05:53:34 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <505C6348.1060804@redhat.com> Date: Fri, 21 Sep 2012 14:53:28 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1348217255-22441-1-git-send-email-quintela@redhat.com> <1348217255-22441-39-git-send-email-quintela@redhat.com> In-Reply-To: <1348217255-22441-39-git-send-email-quintela@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 38/41] block-migration: handle errors with the return codes correctly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org Il 21/09/2012 10:47, Juan Quintela ha scritto: > Signed-off-by: Juan Quintela > --- > block-migration.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > > diff --git a/block-migration.c b/block-migration.c > index 565628f..9f94733 100644 > --- a/block-migration.c > +++ b/block-migration.c > @@ -423,10 +423,9 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds, > > error: > DPRINTF("Error reading sector %" PRId64 "\n", sector); > - qemu_file_set_error(f, ret); > g_free(blk->buf); > g_free(blk); > - return 0; > + return ret; > } > > /* return value: > @@ -440,7 +439,7 @@ static int blk_mig_save_dirty_block(QEMUFile *f, int is_async) > > QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { > ret = mig_save_device_dirty(f, bmds, is_async); > - if (ret == 0) { > + if (ret <= 0) { > break; > } > } > @@ -598,12 +597,17 @@ static int block_save_iterate(QEMUFile *f, void *opaque) > block_mig_state.bulk_completed = 1; > } > } else { > - if (blk_mig_save_dirty_block(f, 1) != 0) { > + ret = blk_mig_save_dirty_block(f, 1); > + if (ret != 0) { > /* no more dirty blocks */ > break; > } > } > } > + if (ret) { > + blk_mig_cleanup(); > + return ret; > + } > > ret = flush_blks(f); > if (ret) { > @@ -635,18 +639,15 @@ static int block_save_complete(QEMUFile *f, void *opaque) > all async read completed */ > assert(block_mig_state.submitted == 0); > Not clear what the fixes are, I'll take it as a cleanup. Then: > - while (blk_mig_save_dirty_block(f, 0) == 0) { > + while ((ret = blk_mig_save_dirty_block(f, 0)) == 0) { > /* Do nothing */ > } use a do...while instead: do { ret = blk_mig_save_dirty_block(f, 0); } while (ret == 0); > blk_mig_cleanup(); > - > - /* report completion */ > - qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); > - > - ret = qemu_file_get_error(f); > if (ret) { > return ret; > } Is it correct that we now return 1? We used to return 0. Paolo > + /* report completion */ > + qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); > > DPRINTF("Block migration completed\n"); >