summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2016-05-17 12:15:42 +0300
committerKevin Wolf <kwolf@redhat.com>2016-05-19 16:45:31 +0200
commitf575f145f4fa97fdbb9bbb4df62dfeada3f15dc4 (patch)
tree0e4ddab1eabc09e27f33e78a9dce275996526b00 /block
parentb97511c7bc88bc487cacbfab349eb6023ae4f49b (diff)
downloadqemu-f575f145f4fa97fdbb9bbb4df62dfeada3f15dc4.tar.gz
qcow2: fix condition in is_zero_cluster
We should check for (res & BDRV_BLOCK_ZERO) only. The situation when we will have !(res & BDRV_BLOCK_DATA) and will not have BDRV_BLOCK_ZERO is not possible for images with bdi.unallocated_blocks_are_zero == true. For those images where it's false, however, it can happen and we must not consider the data zeroed then or we would corrupt the image. Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qcow2.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index 62febfc386..a6012dc793 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2412,7 +2412,7 @@ static bool is_zero_cluster(BlockDriverState *bs, int64_t start)
BlockDriverState *file;
int64_t res = bdrv_get_block_status_above(bs, NULL, start,
s->cluster_sectors, &nr, &file);
- return res >= 0 && ((res & BDRV_BLOCK_ZERO) || !(res & BDRV_BLOCK_DATA));
+ return res >= 0 && (res & BDRV_BLOCK_ZERO);
}
static bool is_zero_cluster_top_locked(BlockDriverState *bs, int64_t start)