cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 8783be68d7f1710ad79903bb7eb20ef12045c1e3 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <8783be68d7f1710ad79903bb7eb20ef12045c1e3.1418766606.git.jen@redhat.com>
9ae3a8
In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
9ae3a8
References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Thu, 4 Dec 2014 00:05:14 -0600
9ae3a8
Subject: [CHANGE 20/31] vmdk: Implement .bdrv_get_info()
9ae3a8
To: rhvirt-patches@redhat.com,
9ae3a8
    jen@redhat.com
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1417651524-18041-21-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 62693
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 20/30] vmdk: Implement .bdrv_get_info()
9ae3a8
Bugzilla: 1134283
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
9ae3a8
RH-Acked-by: Max Reitz <mreitz@redhat.com>
9ae3a8
9ae3a8
This will return cluster_size and needs_compressed_writes to caller, if all the
9ae3a8
extents have the same value (or there's only one extent). Otherwise return
9ae3a8
-ENOTSUP.
9ae3a8
9ae3a8
cluster_size is only reported for sparse formats.
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 74fe188cd1a27a5565787152d8620f8b8d04c4f9)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
9ae3a8
---
9ae3a8
 block/vmdk.c               | 21 +++++++++++++++++++++
9ae3a8
 tests/qemu-iotests/059.out |  1 +
9ae3a8
 2 files changed, 22 insertions(+)
9ae3a8
9ae3a8
diff --git a/block/vmdk.c b/block/vmdk.c
9ae3a8
index 157db7e..94e8782 100644
9ae3a8
--- a/block/vmdk.c
9ae3a8
+++ b/block/vmdk.c
9ae3a8
@@ -2071,6 +2071,26 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)
9ae3a8
     return spec_info;
9ae3a8
 }
9ae3a8
 
9ae3a8
+static int vmdk_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
9ae3a8
+{
9ae3a8
+    int i;
9ae3a8
+    BDRVVmdkState *s = bs->opaque;
9ae3a8
+    assert(s->num_extents);
9ae3a8
+    bdi->needs_compressed_writes = s->extents[0].compressed;
9ae3a8
+    if (!s->extents[0].flat) {
9ae3a8
+        bdi->cluster_size = s->extents[0].cluster_sectors << BDRV_SECTOR_BITS;
9ae3a8
+    }
9ae3a8
+    /* See if we have multiple extents but they have different cases */
9ae3a8
+    for (i = 1; i < s->num_extents; i++) {
9ae3a8
+        if (bdi->needs_compressed_writes != s->extents[i].compressed ||
9ae3a8
+            (bdi->cluster_size && bdi->cluster_size !=
9ae3a8
+                s->extents[i].cluster_sectors << BDRV_SECTOR_BITS)) {
9ae3a8
+            return -ENOTSUP;
9ae3a8
+        }
9ae3a8
+    }
9ae3a8
+    return 0;
9ae3a8
+}
9ae3a8
+
9ae3a8
 static QEMUOptionParameter vmdk_create_options[] = {
9ae3a8
     {
9ae3a8
         .name = BLOCK_OPT_SIZE,
9ae3a8
@@ -2127,6 +2147,7 @@ static BlockDriver bdrv_vmdk = {
9ae3a8
     .bdrv_has_zero_init           = vmdk_has_zero_init,
9ae3a8
     .bdrv_get_specific_info       = vmdk_get_specific_info,
9ae3a8
     .bdrv_refresh_limits          = vmdk_refresh_limits,
9ae3a8
+    .bdrv_get_info                = vmdk_get_info,
9ae3a8
 
9ae3a8
     .create_options               = vmdk_create_options,
9ae3a8
 };
9ae3a8
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
9ae3a8
index 7c9ef90..f226f71 100644
9ae3a8
--- a/tests/qemu-iotests/059.out
9ae3a8
+++ b/tests/qemu-iotests/059.out
9ae3a8
@@ -2050,6 +2050,7 @@ qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least
9ae3a8
 image: TEST_DIR/iotest-version3.IMGFMT
9ae3a8
 file format: IMGFMT
9ae3a8
 virtual size: 1.0G (1073741824 bytes)
9ae3a8
+cluster_size: 65536
9ae3a8
 
9ae3a8
 === Testing 4TB monolithicFlat creation and IO ===
9ae3a8
 Formatting 'TEST_DIR/iotest-version3.IMGFMT', fmt=IMGFMT size=4398046511104
9ae3a8
-- 
9ae3a8
2.1.0
9ae3a8