From: Paolo Bonzini Date: Wed, 4 Sep 2013 17:00:31 +0000 (+0200) Subject: block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~1362^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=415b5b013ce74126e71459b922a92377918ae2ef;p=sdk%2Femulator%2Fqemu.git 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 --- diff --git a/block.c b/block.c index 97406ec..aa9ec83 100644 --- a/block.c +++ b/block.c @@ -3075,6 +3075,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) { @@ -3096,7 +3097,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() */