From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4Vtv-00074a-Av for qemu-devel@nongnu.org; Wed, 31 Jul 2013 08:53:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4Vtq-0007za-S2 for qemu-devel@nongnu.org; Wed, 31 Jul 2013 08:53:11 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:41216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4Vtq-0007zU-K8 for qemu-devel@nongnu.org; Wed, 31 Jul 2013 08:53:06 -0400 Date: Wed, 31 Jul 2013 08:53:03 -0400 (EDT) From: Paolo Bonzini Message-ID: <1299773374.7481321.1375275183549.JavaMail.root@redhat.com> In-Reply-To: <20130731092127.GG3090@dhcp-200-207.str.redhat.com> References: <1374762197-7261-1-git-send-email-pbonzini@redhat.com> <1374762197-7261-20-git-send-email-pbonzini@redhat.com> <20130731092127.GG3090@dhcp-200-207.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 19/19] block: look for zero blocks in bs->file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: pl@kamp.de, qemu-devel@nongnu.org, stefanha@redhat.com ----- Original Message ----- > From: "Kevin Wolf" > To: "Paolo Bonzini" > Cc: qemu-devel@nongnu.org, stefanha@redhat.com, eblake@redhat.com, pl@kamp.de > Sent: Wednesday, July 31, 2013 11:21:27 AM > Subject: Re: [PATCH v3 19/19] block: look for zero blocks in bs->file > > Am 25.07.2013 um 16:23 hat Paolo Bonzini geschrieben: > > Reviewed-by: Eric Blake > > Signed-off-by: Paolo Bonzini > > --- > > block.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/block.c b/block.c > > index 8738937..1493f22 100644 > > --- a/block.c > > +++ b/block.c > > @@ -2991,7 +2991,7 @@ static int64_t coroutine_fn > > bdrv_co_get_block_status(BlockDriverState *bs, > > int nb_sectors, int > > *pnum) > > { > > int64_t n; > > - int64_t ret; > > + int64_t ret, ret2; > > > > if (sector_num >= bs->total_sectors) { > > *pnum = 0; > > @@ -3017,6 +3017,14 @@ static int64_t coroutine_fn > > bdrv_co_get_block_status(BlockDriverState *bs, > > ret |= BDRV_BLOCK_ZERO; > > } > > > > + if (bs->file && > > + (ret & BDRV_BLOCK_DATA) && !(ret & BDRV_BLOCK_ZERO) && > > + (ret & BDRV_BLOCK_OFFSET_VALID)) { > > + ret2 = bdrv_co_get_block_status(bs->file, ret >> BDRV_SECTOR_BITS, > > + *pnum, pnum); > > Here the error check is missing, too. Right. Here I can ignore errors, but I should still check ret2 >= 0 before taking random bits out of it. Paolo > > > + ret |= (ret2 & BDRV_BLOCK_ZERO); > > + } > > + > > return ret; > > } > > Kevin >