Blob Blame Raw
From a21710237f6c2cce366515fc2dacd4211bc31b7a Mon Sep 17 00:00:00 2001
From: Fam Zheng <famz@redhat.com>
Date: Mon, 14 Jul 2014 02:05:27 -0500
Subject: [CHANGE 22/29] vmdk: Fix format specific information (create type)
 for streamOptimized
To: rhvirt-patches@redhat.com,
    jen@redhat.com

RH-Author: Fam Zheng <famz@redhat.com>
Message-id: <1405303527-10117-1-git-send-email-famz@redhat.com>
Patchwork-id: 59872
O-Subject: [RHEL-7 qemu-kvm PATCH] vmdk: Fix format specific information (create type) for streamOptimized
Bugzilla: 1029271
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1029271
Brew:     http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7695829

Previously the field is wrong:

    $ ./qemu-img create -f vmdk -o subformat=streamOptimized /tmp/a.vmdk 1G

    $ ./qemu-img info /tmp/a.vmdk
    image: /tmp/a.vmdk
    file format: vmdk
    virtual size: 1.0G (1073741824 bytes)
    disk size: 12K
    Format specific information:
        cid: 1390460459
        parent cid: 4294967295
>>>     create type: monolithicSparse
        <snip>

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit d8a7b061ae01e5692cc994f05ad6480d8c170125)
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/vmdk.c | 4 ++++
 1 file changed, 4 insertions(+)

Signed-off-by: jen <jen@redhat.com>
---
 block/vmdk.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/vmdk.c b/block/vmdk.c
index a966715..9e4b3b9 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -650,6 +650,10 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
     }
     extent->compressed =
         le16_to_cpu(header.compressAlgorithm) == VMDK4_COMPRESSION_DEFLATE;
+    if (extent->compressed) {
+        g_free(s->create_type);
+        s->create_type = g_strdup("streamOptimized");
+    }
     extent->has_marker = le32_to_cpu(header.flags) & VMDK4_FLAG_MARKER;
     extent->version = le32_to_cpu(header.version);
     extent->has_zero_grain = le32_to_cpu(header.flags) & VMDK4_FLAG_ZERO_GRAIN;
-- 
1.9.3