From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGDKW-0000Bj-Pn for qemu-devel@nongnu.org; Mon, 24 Sep 2012 14:24:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TGDKV-0003xi-Lv for qemu-devel@nongnu.org; Mon, 24 Sep 2012 14:24:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TGDKV-0003xZ-Cf for qemu-devel@nongnu.org; Mon, 24 Sep 2012 14:24:27 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8OIOQ2p013522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 24 Sep 2012 14:24:26 -0400 From: Juan Quintela In-Reply-To: <505C6348.1060804@redhat.com> (Paolo Bonzini's message of "Fri, 21 Sep 2012 14:53:28 +0200") References: <1348217255-22441-1-git-send-email-quintela@redhat.com> <1348217255-22441-39-git-send-email-quintela@redhat.com> <505C6348.1060804@redhat.com> Date: Mon, 24 Sep 2012 20:24:24 +0200 Message-ID: <87a9wfqnxj.fsf@trasno.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 38/41] block-migration: handle errors with the return codes correctly Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Paolo Bonzini wrote: > Il 21/09/2012 10:47, Juan Quintela ha scritto: >> Signed-off-by: Juan Quintela >> --- >> @@ -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: We are returning now the errors directly. Until now, we were > >> - 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); I wanted to minimize the changes, but I don't really care, > >> 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. If you look at the whole change, old code was: while (blk_mig_save_dirty_block(f, 0) != 0) { /* Do nothing */ } 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; } DPRINTF("Block migration completed\n"); qemu_put_be64(f, BLK_MIG_FLAG_EOS); return 0; i.e. if there is one error, we return it, otherwise, we return 0. while ((ret = blk_mig_save_dirty_block(f, 0)) == 0) { /* Do nothing */ } blk_mig_cleanup(); if (ret) { return ret; } /* report completion */ qemu_put_be64(f, (100 << BDRV_SECTOR_BITS) | BLK_MIG_FLAG_PROGRESS); DPRINTF("Block migration completed\n"); qemu_put_be64(f, BLK_MIG_FLAG_EOS); return 0; Now, we give exactly the same error, just that we return the error directly from blk_mig_save_dirty_block() instead of storing it on QEMUFile and getting it through qemu_file_get_error(). Notice that between old code and the _newer_ code, we have reverted the return value of blk_mig_save_block to make things more consistent. Later, Juan.