This will return cluster_size and is_compressed to caller, if all the extents has the same value (or there's only one extent). Otherwise return -ENOTSUP.
Signed-off-by: Fam Zheng <f...@redhat.com> --- block/vmdk.c | 19 +++++++++++++++++++ tests/qemu-iotests/059.out | 1 + 2 files changed, 20 insertions(+) diff --git a/block/vmdk.c b/block/vmdk.c index f439206..07f77d8 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1905,6 +1905,24 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs) return spec_info; } +static int vmdk_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + int i; + BDRVVmdkState *s = bs->opaque; + assert(s->num_extents); + bdi->is_compressed = s->extents[0].compressed; + bdi->cluster_size = s->extents[0].cluster_sectors << BDRV_SECTOR_BITS; + /* See if we have multiple extents but they have different cases */ + for (i = 1; i < s->num_extents; i++) { + if (bdi->is_compressed != s->extents[i].compressed || + bdi->cluster_size != + s->extents[i].cluster_sectors << BDRV_SECTOR_BITS) { + return -ENOTSUP; + } + } + return 0; +} + static QEMUOptionParameter vmdk_create_options[] = { { .name = BLOCK_OPT_SIZE, @@ -1959,6 +1977,7 @@ static BlockDriver bdrv_vmdk = { .bdrv_get_allocated_file_size = vmdk_get_allocated_file_size, .bdrv_has_zero_init = vmdk_has_zero_init, .bdrv_get_specific_info = vmdk_get_specific_info, + .bdrv_get_info = vmdk_get_info, .create_options = vmdk_create_options, }; diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out index 2ded8a9..8394d14 100644 --- a/tests/qemu-iotests/059.out +++ b/tests/qemu-iotests/059.out @@ -21,6 +21,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 2.0G (2147483648 bytes) +cluster_size: 2147483648 === Testing monolithicFlat with zeroed_grain === qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain -- 1.8.4.2