Commit 509d39aa authored by Fam Zheng's avatar Fam Zheng Committed by Kevin Wolf
Browse files

vmdk: Allow read only open of VMDK version 3



Signed-off-by: default avatarFam Zheng <famz@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent c34b8012
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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) {