render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0102-vmdk-Fix-converting-to-streamOptimized.patch

7d975d
From: Fam Zheng <famz@redhat.com>
7d975d
Date: Mon, 25 Jan 2016 10:26:23 +0800
7d975d
Subject: [PATCH] vmdk: Fix converting to streamOptimized
7d975d
7d975d
Commit d62d9dc4b8 lifted streamOptimized images's version to 3, but we
7d975d
now refuse to open version 3 images read-write.  We need to make
7d975d
streamOptimized an exception to allow converting to it. This fixes the
7d975d
accidentally broken iotests case 059 for the same reason.
7d975d
7d975d
Signed-off-by: Fam Zheng <famz@redhat.com>
7d975d
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7d975d
Signed-off-by: Max Reitz <mreitz@redhat.com>
7d975d
(cherry picked from commit 3db1d98a20262228373bb973ca62b1ab64b29af4)
7d975d
---
7d975d
 block/vmdk.c | 6 +++++-
7d975d
 1 file changed, 5 insertions(+), 1 deletion(-)
7d975d
7d975d
diff --git a/block/vmdk.c b/block/vmdk.c
7d975d
index 26b76d9..e46271a 100644
7d975d
--- a/block/vmdk.c
7d975d
+++ b/block/vmdk.c
7d975d
@@ -570,6 +570,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
7d975d
     VmdkExtent *extent;
7d975d
     BDRVVmdkState *s = bs->opaque;
7d975d
     int64_t l1_backup_offset = 0;
7d975d
+    bool compressed;
7d975d
 
7d975d
     ret = bdrv_pread(file->bs, sizeof(magic), &header, sizeof(header));
7d975d
     if (ret < 0) {
7d975d
@@ -644,6 +645,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
7d975d
         header = footer.header;
7d975d
     }
7d975d
 
7d975d
+    compressed =
7d975d
+        le16_to_cpu(header.compressAlgorithm) == VMDK4_COMPRESSION_DEFLATE;
7d975d
     if (le32_to_cpu(header.version) > 3) {
7d975d
         char buf[64];
7d975d
         snprintf(buf, sizeof(buf), "VMDK version %" PRId32,
7d975d
@@ -651,7 +654,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
7d975d
         error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
7d975d
                    bdrv_get_device_or_node_name(bs), "vmdk", buf);
7d975d
         return -ENOTSUP;
7d975d
-    } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
7d975d
+    } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR) &&
7d975d
+               !compressed) {
7d975d
         /* VMware KB 2064959 explains that version 3 added support for
7d975d
          * persistent changed block tracking (CBT), and backup software can
7d975d
          * read it as version=1 if it doesn't care about the changed area