summaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-09-04 19:00:38 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2013-09-06 15:25:09 +0200
commit5daa74a6ebce7543aaad178c4061dc087bb4c705 (patch)
treeaa338ce4ff4b3549004a3446b2f072bd2e26a2d9 /block.c
parent918e92d71b38306a6bf4fedfd1109367f1425587 (diff)
downloadhqemu-5daa74a6ebce7543aaad178c4061dc087bb4c705.zip
hqemu-5daa74a6ebce7543aaad178c4061dc087bb4c705.tar.gz
block: look for zero blocks in bs->file
Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/block.c b/block.c
index 3c39769..a325efc 100644
--- a/block.c
+++ b/block.c
@@ -3075,7 +3075,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
{
int64_t length;
int64_t n;
- int64_t ret;
+ int64_t ret, ret2;
length = bdrv_getlength(bs);
if (length < 0) {
@@ -3117,6 +3117,20 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs,
}
}
}
+
+ 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);
+ if (ret2 >= 0) {
+ /* Ignore errors. This is just providing extra information, it
+ * is useful but not necessary.
+ */
+ ret |= (ret2 & BDRV_BLOCK_ZERO);
+ }
+ }
+
return ret;
}
OpenPOWER on IntegriCloud