From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, gentoo.integer@gmail.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v4 3/4] vmdk: Implement .bdrv_get_info()
Date: Tue, 6 May 2014 21:08:45 +0800 [thread overview]
Message-ID: <1399381726-8078-4-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1399381726-8078-1-git-send-email-famz@redhat.com>
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>
---
block/vmdk.c | 21 +++++++++++++++++++++
tests/qemu-iotests/059.out | 1 +
2 files changed, 22 insertions(+)
diff --git a/block/vmdk.c b/block/vmdk.c
index a7783f7..ab18ece 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -2090,6 +2090,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,
@@ -2146,6 +2166,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,
};
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
index 3371c86..14c0957 100644
--- a/tests/qemu-iotests/059.out
+++ b/tests/qemu-iotests/059.out
@@ -2050,6 +2050,7 @@ qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least
image: TEST_DIR/iotest-version3.IMGFMT
file format: IMGFMT
virtual size: 1.0G (1073741824 bytes)
+cluster_size: 65536
=== Testing 4TB monolithicFlat creation and IO ===
Formatting 'TEST_DIR/iotest-version3.IMGFMT', fmt=IMGFMT size=4398046511104
--
1.9.2
next prev parent reply other threads:[~2014-05-06 13:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-06 13:08 [Qemu-devel] [PATCH v4 0/4] Fix conversion from ISO to VMDK streamOptimized Fam Zheng
2014-05-06 13:08 ` [Qemu-devel] [PATCH v4 1/4] qemu-img: Convert by cluster size if target is compressed Fam Zheng
2014-05-06 13:08 ` [Qemu-devel] [PATCH v4 2/4] vmdk: Implement .bdrv_write_compressed Fam Zheng
2014-05-06 13:08 ` Fam Zheng [this message]
2014-05-06 13:08 ` [Qemu-devel] [PATCH v4 4/4] qemu-iotests: Test converting to streamOptimized from small cluster size Fam Zheng
2014-05-06 14:19 ` [Qemu-devel] [PATCH v4 0/4] Fix conversion from ISO to VMDK streamOptimized Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399381726-8078-4-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=gentoo.integer@gmail.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).