peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0043-vmdk-fix-cluster-size-check-for-flat-extents.patch

298366
From 61fbeb6e81f648d25c2d3ba5f0d663d54abed1c1 Mon Sep 17 00:00:00 2001
298366
From: Fam Zheng <famz@redhat.com>
298366
Date: Mon, 23 Sep 2013 17:18:29 +0800
298366
Subject: [PATCH] vmdk: fix cluster size check for flat extents
298366
298366
We use the extent size as cluster size for flat extents (where no L1/L2
298366
table is allocated so it's safe) reuse sector calculating code with
298366
sparse extents.
298366
298366
Don't pass in the cluster size for adding flat extent, just set it to
298366
sectors later, then the cluster size checking will not fail.
298366
298366
The cluster_sectors is changed to int64_t to allow big flat extent.
298366
298366
Without this, flat extent opening is broken:
298366
298366
    # qemu-img create -f vmdk -o subformat=monolithicFlat /tmp/a.vmdk 100G
298366
    Formatting '/tmp/a.vmdk', fmt=vmdk size=107374182400 compat6=off subformat='monolithicFlat' zeroed_grain=off
298366
    # qemu-img info /tmp/a.vmdk
298366
    image: /tmp/a.vmdk
298366
    file format: raw
298366
    virtual size: 0 (0 bytes)
298366
    disk size: 4.0K
298366
298366
Signed-off-by: Fam Zheng <famz@redhat.com>
298366
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
298366
(cherry picked from commit 301c7d38a0c359b91526391d13617386f3d9bb29)
298366
298366
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
298366
---
298366
 block/vmdk.c | 6 +++---
298366
 1 file changed, 3 insertions(+), 3 deletions(-)
298366
298366
diff --git a/block/vmdk.c b/block/vmdk.c
298366
index 346bb5c..258a24f 100644
298366
--- a/block/vmdk.c
298366
+++ b/block/vmdk.c
298366
@@ -105,7 +105,7 @@ typedef struct VmdkExtent {
298366
     uint32_t l2_cache_offsets[L2_CACHE_SIZE];
298366
     uint32_t l2_cache_counts[L2_CACHE_SIZE];
298366
 
298366
-    unsigned int cluster_sectors;
298366
+    int64_t cluster_sectors;
298366
 } VmdkExtent;
298366
 
298366
 typedef struct BDRVVmdkState {
298366
@@ -416,7 +416,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
298366
     extent->l1_size = l1_size;
298366
     extent->l1_entry_sectors = l2_size * cluster_sectors;
298366
     extent->l2_size = l2_size;
298366
-    extent->cluster_sectors = cluster_sectors;
298366
+    extent->cluster_sectors = flat ? sectors : cluster_sectors;
298366
 
298366
     if (s->num_extents > 1) {
298366
         extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
298366
@@ -736,7 +736,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
298366
             VmdkExtent *extent;
298366
 
298366
             ret = vmdk_add_extent(bs, extent_file, true, sectors,
298366
-                            0, 0, 0, 0, sectors, &extent);
298366
+                            0, 0, 0, 0, 0, &extent);
298366
             if (ret < 0) {
298366
                 return ret;
298366
             }