From 11212d8fa08a4e5bd56bb4f6877f9a4c0439a02b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 4 Sep 2013 19:00:27 +0200 Subject: block: make bdrv_has_zero_init return false for copy-on-write-images This helps implementing is_allocated on top of get_block_status. Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- block.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'block.c') diff --git a/block.c b/block.c index 5df17de5a4..2a90893464 100644 --- a/block.c +++ b/block.c @@ -3031,6 +3031,11 @@ int bdrv_has_zero_init(BlockDriverState *bs) { assert(bs->drv); + /* If BS is a copy on write image, it is initialized to + the contents of the base image, which may not be zeroes. */ + if (bs->backing_hd) { + return 0; + } if (bs->drv->bdrv_has_zero_init) { return bs->drv->bdrv_has_zero_init(bs); } -- cgit v1.2.3