|
|
218e99 |
From cbffbb8195ec5370cbb2baf53148806b5a1c3dc8 Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
Date: Wed, 9 Oct 2013 09:50:22 +0200
|
|
|
218e99 |
Subject: [PATCH 10/11] vmdk: fix cluster size check for flat extents
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
Message-id: <1381312223-7074-3-git-send-email-famz@redhat.com>
|
|
|
218e99 |
Patchwork-id: 54794
|
|
|
218e99 |
O-Subject: [RHEL-7 qemu-kvm PATCH 2/3] vmdk: fix cluster size check for flat extents
|
|
|
218e99 |
Bugzilla: 1017049
|
|
|
218e99 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
We use the extent size as cluster size for flat extents (where no L1/L2
|
|
|
218e99 |
table is allocated so it's safe) reuse sector calculating code with
|
|
|
218e99 |
sparse extents.
|
|
|
218e99 |
|
|
|
218e99 |
Don't pass in the cluster size for adding flat extent, just set it to
|
|
|
218e99 |
sectors later, then the cluster size checking will not fail.
|
|
|
218e99 |
|
|
|
218e99 |
The cluster_sectors is changed to int64_t to allow big flat extent.
|
|
|
218e99 |
|
|
|
218e99 |
Without this, flat extent opening is broken:
|
|
|
218e99 |
|
|
|
218e99 |
# qemu-img create -f vmdk -o subformat=monolithicFlat /tmp/a.vmdk 100G
|
|
|
218e99 |
Formatting '/tmp/a.vmdk', fmt=vmdk size=107374182400 compat6=off subformat='monolithicFlat' zeroed_grain=off
|
|
|
218e99 |
# qemu-img info /tmp/a.vmdk
|
|
|
218e99 |
image: /tmp/a.vmdk
|
|
|
218e99 |
file format: raw
|
|
|
218e99 |
virtual size: 0 (0 bytes)
|
|
|
218e99 |
disk size: 4.0K
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
(cherry picked from commit 301c7d38a0c359b91526391d13617386f3d9bb29)
|
|
|
218e99 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block/vmdk.c | 6 +++---
|
|
|
218e99 |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block/vmdk.c | 6 +++---
|
|
|
218e99 |
1 files changed, 3 insertions(+), 3 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
218e99 |
index b0b419b..66735ab 100644
|
|
|
218e99 |
--- a/block/vmdk.c
|
|
|
218e99 |
+++ b/block/vmdk.c
|
|
|
218e99 |
@@ -105,7 +105,7 @@ typedef struct VmdkExtent {
|
|
|
218e99 |
uint32_t l2_cache_offsets[L2_CACHE_SIZE];
|
|
|
218e99 |
uint32_t l2_cache_counts[L2_CACHE_SIZE];
|
|
|
218e99 |
|
|
|
218e99 |
- unsigned int cluster_sectors;
|
|
|
218e99 |
+ int64_t cluster_sectors;
|
|
|
218e99 |
} VmdkExtent;
|
|
|
218e99 |
|
|
|
218e99 |
typedef struct BDRVVmdkState {
|
|
|
218e99 |
@@ -424,7 +424,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
|
|
|
218e99 |
extent->l1_size = l1_size;
|
|
|
218e99 |
extent->l1_entry_sectors = l2_size * cluster_sectors;
|
|
|
218e99 |
extent->l2_size = l2_size;
|
|
|
218e99 |
- extent->cluster_sectors = cluster_sectors;
|
|
|
218e99 |
+ extent->cluster_sectors = flat ? sectors : cluster_sectors;
|
|
|
218e99 |
|
|
|
218e99 |
if (s->num_extents > 1) {
|
|
|
218e99 |
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
|
|
|
218e99 |
@@ -737,7 +737,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
|
|
|
218e99 |
VmdkExtent *extent;
|
|
|
218e99 |
|
|
|
218e99 |
ret = vmdk_add_extent(bs, extent_file, true, sectors,
|
|
|
218e99 |
- 0, 0, 0, 0, sectors, &extent);
|
|
|
218e99 |
+ 0, 0, 0, 0, 0, &extent);
|
|
|
218e99 |
if (ret < 0) {
|
|
|
218e99 |
return ret;
|
|
|
218e99 |
}
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|