summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2014-05-06 21:08:45 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2014-05-09 13:32:16 +0200
commit74fe188cd1a27a5565787152d8620f8b8d04c4f9 (patch)
treed3bf49aba27216eee388e3fc43e4de87823552ad /block
parentba0ad89e2c3316ce26ca6576a3c5051f91bfc0fe (diff)
downloadqemu-74fe188cd1a27a5565787152d8620f8b8d04c4f9.tar.gz
qemu-74fe188cd1a27a5565787152d8620f8b8d04c4f9.tar.bz2
qemu-74fe188cd1a27a5565787152d8620f8b8d04c4f9.zip
vmdk: Implement .bdrv_get_info()
This will return cluster_size and needs_compressed_writes to caller, if all the extents have the same value (or there's only one extent). Otherwise return -ENOTSUP. cluster_size is only reported for sparse formats. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/vmdk.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/block/vmdk.c b/block/vmdk.c
index 057c3f1fcd..480ea37d7c 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -2076,6 +2076,26 @@ 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->needs_compressed_writes = s->extents[0].compressed;
+ if (!s->extents[0].flat) {
+ 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->needs_compressed_writes != s->extents[i].compressed ||
+ (bdi->cluster_size && bdi->cluster_size !=
+ s->extents[i].cluster_sectors << BDRV_SECTOR_BITS)) {
+ return -ENOTSUP;
+ }
+ }
+ return 0;
+}
+
static QEMUOptionParameter vmdk_create_options[] = {
{
.name = BLOCK_OPT_SIZE,
@@ -2132,6 +2152,7 @@ static BlockDriver bdrv_vmdk = {
.bdrv_has_zero_init = vmdk_has_zero_init,
.bdrv_get_specific_info = vmdk_get_specific_info,
.bdrv_refresh_limits = vmdk_refresh_limits,
+ .bdrv_get_info = vmdk_get_info,
.create_options = vmdk_create_options,
};