提交 415b5b01 编写于 作者: P Paolo Bonzini 提交者: Stefan Hajnoczi

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: NEric Blake <eblake@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 4bc74be9
...@@ -3075,6 +3075,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, ...@@ -3075,6 +3075,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
{ {
int64_t length; int64_t length;
int64_t n; int64_t n;
int64_t ret;
length = bdrv_getlength(bs); length = bdrv_getlength(bs);
if (length < 0) { if (length < 0) {
...@@ -3096,7 +3097,15 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, ...@@ -3096,7 +3097,15 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
return BDRV_BLOCK_DATA; 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() */ /* Coroutine wrapper for bdrv_get_block_status() */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册