Received: from eggs.gnu.org ([2001:4830:134:3::10]:49573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlqiQ-0003n7-IO for qemu-devel@nongnu.org; Wed, 27 Nov 2013 20:48:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlqiF-0004aZ-Rx for qemu-devel@nongnu.org; Wed, 27 Nov 2013 20:48:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3976) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlqiF-0004aD-JP for qemu-devel@nongnu.org; Wed, 27 Nov 2013 20:48:15 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAS1mD6w012653 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Nov 2013 20:48:14 -0500 From: Fam Zheng Date: Thu, 28 Nov 2013 09:48:03 +0800 Message-Id: <1385603284-20104-2-git-send-email-famz@redhat.com> In-Reply-To: <1385603284-20104-1-git-send-email-famz@redhat.com> References: <1385603284-20104-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 1/2] vmdk: Allow read only open of VMDK version 3 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com Signed-off-by: Fam Zheng --- block/vmdk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/vmdk.c b/block/vmdk.c index a7ebd0f..6fd20dc 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -605,13 +605,20 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, header = footer.header; } - if (le32_to_cpu(header.version) >= 3) { + if (le32_to_cpu(header.version) > 3) { char buf[64]; snprintf(buf, sizeof(buf), "VMDK version %d", le32_to_cpu(header.version)); qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, bs->device_name, "vmdk", buf); return -ENOTSUP; + } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) { + /* VMware KB 2064959 explains that version 3 added support for + * persistent changed block tracking (CBT), and backup software can + * read it as version=1 if it doesn't care about the changed area + * information. So we are safe to enable read only. */ + error_setg(errp, "VMDK version 3 must be read only"); + return -EINVAL; } if (le32_to_cpu(header.num_gtes_per_gt) > 512) { -- 1.8.4.2