qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] vmdk: fix cluster size check for flat extents
@ 2013-09-23  9:18 Fam Zheng
  2013-09-23  9:40 ` Fam Zheng
                   ` (4 more replies)
  0 siblings, 5 replies; 23+ messages in thread
From: Fam Zheng @ 2013-09-23  9:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, stefanha

We use the extent size as cluster size for flat extents (where no L1/L2
table is allocated so it's safe) reuse sector calculating code with
sparse extents.

Don't pass in the cluster size for adding flat extent, just set it to
sectors later, then the cluster size checking will not fail.

The cluster_sectors is changed to int64_t to allow big flat extent.

Without this, flat extent opening is broken:

    # qemu-img create -f vmdk -o subformat=monolithicFlat /tmp/a.vmdk 100G
    Formatting '/tmp/a.vmdk', fmt=vmdk size=107374182400 compat6=off subformat='monolithicFlat' zeroed_grain=off
    # qemu-img info /tmp/a.vmdk
    image: /tmp/a.vmdk
    file format: raw
    virtual size: 0 (0 bytes)
    disk size: 4.0K

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/vmdk.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block/vmdk.c b/block/vmdk.c
index 96ef1b5..5d56e31 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -105,7 +105,7 @@ typedef struct VmdkExtent {
     uint32_t l2_cache_offsets[L2_CACHE_SIZE];
     uint32_t l2_cache_counts[L2_CACHE_SIZE];
 
-    unsigned int cluster_sectors;
+    int64_t cluster_sectors;
 } VmdkExtent;
 
 typedef struct BDRVVmdkState {
@@ -424,7 +424,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
     extent->l1_size = l1_size;
     extent->l1_entry_sectors = l2_size * cluster_sectors;
     extent->l2_size = l2_size;
-    extent->cluster_sectors = cluster_sectors;
+    extent->cluster_sectors = flat ? sectors : cluster_sectors;
 
     if (s->num_extents > 1) {
         extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
@@ -741,7 +741,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
             VmdkExtent *extent;
 
             ret = vmdk_add_extent(bs, extent_file, true, sectors,
-                            0, 0, 0, 0, sectors, &extent);
+                            0, 0, 0, 0, 0, &extent);
             if (ret < 0) {
                 return ret;
             }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2013-09-26  2:29 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-23  9:18 [Qemu-devel] [PATCH v2] vmdk: fix cluster size check for flat extents Fam Zheng
2013-09-23  9:40 ` Fam Zheng
2013-09-24  2:41 ` [Qemu-devel] [PATCH 0/2] Fix and add test into 059 Fam Zheng
2013-09-24  2:49   ` [Qemu-devel] [PATCH 1/2] qemu-iotests: fix test case 059 Fam Zheng
2013-09-24  2:49     ` [Qemu-devel] [PATCH 2/2] qemu-iotests: add monolithicFlat creation test to 059 Fam Zheng
2013-09-24 12:49     ` [Qemu-devel] [PATCH 1/2] qemu-iotests: fix test case 059 Stefan Hajnoczi
2013-09-25  0:58       ` Fam Zheng
2013-09-25  7:17         ` Stefan Hajnoczi
2013-09-25  1:14   ` [Qemu-devel] [PATCH v2 0/2] Fix and add test into 059 Fam Zheng
2013-09-25  1:14     ` [Qemu-devel] [PATCH v2 1/2] qemu-iotests: fix test case 059 Fam Zheng
2013-09-25  1:14     ` [Qemu-devel] [PATCH v2 2/2] qemu-iotests: add monolithicFlat creation test to 059 Fam Zheng
2013-09-25  8:27       ` Kevin Wolf
2013-09-25  8:38         ` Fam Zheng
2013-09-25  9:06   ` [Qemu-devel] [PATCH v3 0/2] Fix and add test into 059 Fam Zheng
2013-09-25  9:06     ` [Qemu-devel] [PATCH v3 1/2] qemu-iotests: fix test case 059 Fam Zheng
2013-09-25  9:06     ` [Qemu-devel] [PATCH v3 2/2] qemu-iotests: add monolithicFlat creation test to 059 Fam Zheng
2013-09-25  9:45   ` [Qemu-devel] [PATCH v4 0/2] Fix and add test into 059 Fam Zheng
2013-09-25  9:45     ` [Qemu-devel] [PATCH v4 1/2] qemu-iotests: fix test case 059 Fam Zheng
2013-09-25  9:45     ` [Qemu-devel] [PATCH v4 2/2] qemu-iotests: add monolithicFlat creation test to 059 Fam Zheng
2013-09-25 10:20     ` [Qemu-devel] [PATCH v4 0/2] Fix and add test into 059 Kevin Wolf
2013-09-24  2:42 ` [Qemu-devel] [PATCH v2 " Fam Zheng
2013-09-24 12:53 ` [Qemu-devel] [PATCH v2] vmdk: fix cluster size check for flat extents Stefan Hajnoczi
2013-09-26  2:29 ` Fam Zheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).