cryptospore / rpms / qemu-kvm

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