yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From b42dc567a9071719d730393e717ade1db25c1994 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <b42dc567a9071719d730393e717ade1db25c1994.1387384437.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <58a5fcf24b76c3cf80d671c215b59a0fef76a5c5.1387384437.git.minovotn@redhat.com>
9ae3a8
References: <58a5fcf24b76c3cf80d671c215b59a0fef76a5c5.1387384437.git.minovotn@redhat.com>
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Tue, 10 Dec 2013 02:06:52 +0100
9ae3a8
Subject: [PATCH 2/2] vmdk: Allow read only open of VMDK version 3
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1386641212-24945-1-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 56099
9ae3a8
O-Subject: [RHEL-7 qemu-kvm PATCH] vmdk: Allow read only open of VMDK version 3
9ae3a8
Bugzilla: 1007710
9ae3a8
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
9ae3a8
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1029852
9ae3a8
Brew:     https://brewweb.devel.redhat.com/taskinfo?taskID=6698629
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 509d39aa22909c0ed1aabf896865f19c81fb38a1)
9ae3a8
9ae3a8
Upstream commit doesn't have a verbose commit message, but as the
9ae3a8
comment says, VMware KB 2064959 [1] advises that backup software can
9ae3a8
read version=3 as version=1. This is important for virt-v2v and helps in
9ae3a8
importing VMware VMs from vSphere, since most of the vSphere exported
9ae3a8
OVF/OVA's come with version=3.
9ae3a8
9ae3a8
[1]: http://kb.vmware.com/kb/2064959
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
---
9ae3a8
 block/vmdk.c | 9 ++++++++-
9ae3a8
 1 file changed, 8 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 block/vmdk.c | 9 ++++++++-
9ae3a8
 1 file changed, 8 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
diff --git a/block/vmdk.c b/block/vmdk.c
9ae3a8
index 026b440..7ec6427 100644
9ae3a8
--- a/block/vmdk.c
9ae3a8
+++ b/block/vmdk.c
9ae3a8
@@ -605,13 +605,20 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
9ae3a8
         header = footer.header;
9ae3a8
     }
9ae3a8
 
9ae3a8
-    if (le32_to_cpu(header.version) >= 3) {
9ae3a8
+    if (le32_to_cpu(header.version) > 3) {
9ae3a8
         char buf[64];
9ae3a8
         snprintf(buf, sizeof(buf), "VMDK version %d",
9ae3a8
                  le32_to_cpu(header.version));
9ae3a8
         qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
9ae3a8
                 bs->device_name, "vmdk", buf);
9ae3a8
         return -ENOTSUP;
9ae3a8
+    } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
9ae3a8
+        /* VMware KB 2064959 explains that version 3 added support for
9ae3a8
+         * persistent changed block tracking (CBT), and backup software can
9ae3a8
+         * read it as version=1 if it doesn't care about the changed area
9ae3a8
+         * information. So we are safe to enable read only. */
9ae3a8
+        error_setg(errp, "VMDK version 3 must be read only");
9ae3a8
+        return -EINVAL;
9ae3a8
     }
9ae3a8
 
9ae3a8
     if (le32_to_cpu(header.num_gtes_per_gt) > 512) {
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8