From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uz891-0002J2-Js for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:30:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uz890-0006Dr-8v for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:30:31 -0400 Received: from mail-qc0-x232.google.com ([2607:f8b0:400d:c01::232]:59486) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uz890-0006Da-4B for qemu-devel@nongnu.org; Tue, 16 Jul 2013 12:30:30 -0400 Received: by mail-qc0-f178.google.com with SMTP id c11so498334qcv.9 for ; Tue, 16 Jul 2013 09:30:29 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 16 Jul 2013 18:29:28 +0200 Message-Id: <1373992168-26043-18-git-send-email-pbonzini@redhat.com> In-Reply-To: <1373992168-26043-1-git-send-email-pbonzini@redhat.com> References: <1373992168-26043-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 17/17] 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: pl@kamp.de, famz@redhat.com, stefanha@redhat.com Signed-off-by: Paolo Bonzini --- block.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 557ce29..2d7d71f 100644 --- a/block.c +++ b/block.c @@ -2977,7 +2977,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; @@ -3003,6 +3003,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