From 11fadf68df08c35e9cea52d8d06a19cfc203b700 Mon Sep 17 00:00:00 2001 Message-Id: <11fadf68df08c35e9cea52d8d06a19cfc203b700.1379425497.git.minovotn@redhat.com> In-Reply-To: References: From: Paolo Bonzini Date: Fri, 6 Sep 2013 18:12:40 +0200 Subject: [PATCH 20/25] block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO Alternatively, this could use a "discard zeroes data" flag returned by bdrv_get_info. Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi (cherry picked from commit 415b5b013ce74126e71459b922a92377918ae2ef) Signed-off-by: Michal Novotny --- block.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index ed6cd3f..947b1b2 100644 --- a/block.c +++ b/block.c @@ -2750,6 +2750,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, { int64_t length; int64_t n; + int64_t ret; length = bdrv_getlength(bs); if (length < 0) { @@ -2771,7 +2772,15 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, return BDRV_BLOCK_DATA; } - return bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum); + ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum); + if (ret < 0) { + return ret; + } + + if (!(ret & BDRV_BLOCK_DATA) && bdrv_has_zero_init(bs)) { + ret |= BDRV_BLOCK_ZERO; + } + return ret; } /* Coroutine wrapper for bdrv_get_block_status() */ -- 1.7.11.7