From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2MTJ-0004dF-2U for qemu-devel@nongnu.org; Thu, 25 Jul 2013 10:24:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2MTH-00081q-CV for qemu-devel@nongnu.org; Thu, 25 Jul 2013 10:24:48 -0400 Received: from mail-gh0-x236.google.com ([2607:f8b0:4002:c05::236]:37631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2MTH-00081e-9H for qemu-devel@nongnu.org; Thu, 25 Jul 2013 10:24:47 -0400 Received: by mail-gh0-f182.google.com with SMTP id z15so489833ghb.41 for ; Thu, 25 Jul 2013 07:24:47 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 25 Jul 2013 16:23:17 +0200 Message-Id: <1374762197-7261-20-git-send-email-pbonzini@redhat.com> In-Reply-To: <1374762197-7261-1-git-send-email-pbonzini@redhat.com> References: <1374762197-7261-1-git-send-email-pbonzini@redhat.com> Subject: [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: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pl@kamp.de, stefanha@redhat.com 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); + ret |= (ret2 & BDRV_BLOCK_ZERO); + } + return ret; } -- 1.8.3.1