aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2020-05-28 12:44:04 +0300
committerMax Reitz <mreitz@redhat.com>2020-07-06 10:34:14 +0200
commita2adbbf603cee443ca923f6e8546267a706567d5 (patch)
treedb3c6df1347a108d1a39791cf8a3a8b22c9fee6a /block
parentcdf9ebf18f32f4b29f99af58e154a9afe93bbc92 (diff)
downloadqemu-a2adbbf603cee443ca923f6e8546267a706567d5.zip
qemu-a2adbbf603cee443ca923f6e8546267a706567d5.tar.gz
qemu-a2adbbf603cee443ca923f6e8546267a706567d5.tar.bz2
block: drop unallocated_blocks_are_zero
Currently this field only set by qed and qcow2. But in fact, all backing-supporting formats (parallels, qcow, qcow2, qed, vmdk) share these semantics: on unallocated blocks, if there is no backing file they just memset the buffer with zeroes. So, document this behavior for .supports_backing and drop .unallocated_blocks_are_zero Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200528094405.145708-10-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/io.c9
-rw-r--r--block/qcow2.c1
-rw-r--r--block/qed.c1
3 files changed, 2 insertions, 9 deletions
diff --git a/block/io.c b/block/io.c
index 36d4d56..b6564e3 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2406,7 +2406,7 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
ret |= BDRV_BLOCK_ALLOCATED;
- } else if (want_zero) {
+ } else if (want_zero && bs->drv->supports_backing) {
if (bs->backing) {
BlockDriverState *bs2 = bs->backing->bs;
int64_t size2 = bdrv_getlength(bs2);
@@ -2415,12 +2415,7 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
ret |= BDRV_BLOCK_ZERO;
}
} else {
- BlockDriverInfo bdi;
- int ret2 = bdrv_get_info(bs, &bdi);
-
- if (ret2 == 0 && bdi.unallocated_blocks_are_zero) {
- ret |= BDRV_BLOCK_ZERO;
- }
+ ret |= BDRV_BLOCK_ZERO;
}
}
diff --git a/block/qcow2.c b/block/qcow2.c
index 30f073c..38198b4 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -4987,7 +4987,6 @@ err:
static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVQcow2State *s = bs->opaque;
- bdi->unallocated_blocks_are_zero = true;
bdi->cluster_size = s->cluster_size;
bdi->vm_state_offset = qcow2_vm_state_offset(s);
return 0;
diff --git a/block/qed.c b/block/qed.c
index c0c6501..a2dd952 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1514,7 +1514,6 @@ static int bdrv_qed_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
memset(bdi, 0, sizeof(*bdi));
bdi->cluster_size = s->header.cluster_size;
bdi->is_dirty = s->header.features & QED_F_NEED_CHECK;
- bdi->unallocated_blocks_are_zero = true;
return 0;
}