|
|
9ae3a8 |
From 1826fdaaacd0d6898bb3bd64935edd520dd95428 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 6 Aug 2013 15:44:48 +0800
|
|
|
9ae3a8 |
Subject: [PATCH 02/13] vmdk: use unsigned values for on disk header fields
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1377573001-27070-3-git-send-email-famz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 53782
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH 02/13] vmdk: use unsigned values for on disk
|
|
|
9ae3a8 |
header fields
|
|
|
9ae3a8 |
Bugzilla: 995866
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The size and offset fields are all non-negative values, use uint64_t for
|
|
|
9ae3a8 |
them to avoid getting negative in memory value by int overflow.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit e98768d43799cd3f00b358bfbe455fdae793d3e8)
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/vmdk.c | 24 ++++++++++++------------
|
|
|
9ae3a8 |
1 files changed, 12 insertions(+), 12 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
9ae3a8 |
index e85f4ea..78ea480 100644
|
|
|
9ae3a8 |
--- a/block/vmdk.c
|
|
|
9ae3a8 |
+++ b/block/vmdk.c
|
|
|
9ae3a8 |
@@ -67,14 +67,14 @@ typedef struct {
|
|
|
9ae3a8 |
typedef struct {
|
|
|
9ae3a8 |
uint32_t version;
|
|
|
9ae3a8 |
uint32_t flags;
|
|
|
9ae3a8 |
- int64_t capacity;
|
|
|
9ae3a8 |
- int64_t granularity;
|
|
|
9ae3a8 |
- int64_t desc_offset;
|
|
|
9ae3a8 |
- int64_t desc_size;
|
|
|
9ae3a8 |
- int32_t num_gtes_per_gte;
|
|
|
9ae3a8 |
- int64_t rgd_offset;
|
|
|
9ae3a8 |
- int64_t gd_offset;
|
|
|
9ae3a8 |
- int64_t grain_offset;
|
|
|
9ae3a8 |
+ uint64_t capacity;
|
|
|
9ae3a8 |
+ uint64_t granularity;
|
|
|
9ae3a8 |
+ uint64_t desc_offset;
|
|
|
9ae3a8 |
+ uint64_t desc_size;
|
|
|
9ae3a8 |
+ uint32_t num_gtes_per_gte;
|
|
|
9ae3a8 |
+ uint64_t rgd_offset;
|
|
|
9ae3a8 |
+ uint64_t gd_offset;
|
|
|
9ae3a8 |
+ uint64_t grain_offset;
|
|
|
9ae3a8 |
char filler[1];
|
|
|
9ae3a8 |
char check_bytes[4];
|
|
|
9ae3a8 |
uint16_t compressAlgorithm;
|
|
|
9ae3a8 |
@@ -109,7 +109,7 @@ typedef struct VmdkExtent {
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
typedef struct BDRVVmdkState {
|
|
|
9ae3a8 |
CoMutex lock;
|
|
|
9ae3a8 |
- int desc_offset;
|
|
|
9ae3a8 |
+ uint64_t desc_offset;
|
|
|
9ae3a8 |
bool cid_updated;
|
|
|
9ae3a8 |
uint32_t parent_cid;
|
|
|
9ae3a8 |
int num_extents;
|
|
|
9ae3a8 |
@@ -490,7 +490,7 @@ static int vmdk_open_vmdk3(BlockDriverState *bs,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
|
|
|
9ae3a8 |
- int64_t desc_offset);
|
|
|
9ae3a8 |
+ uint64_t desc_offset);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|
|
9ae3a8 |
BlockDriverState *file,
|
|
|
9ae3a8 |
@@ -508,7 +508,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (header.capacity == 0) {
|
|
|
9ae3a8 |
- int64_t desc_offset = le64_to_cpu(header.desc_offset);
|
|
|
9ae3a8 |
+ uint64_t desc_offset = le64_to_cpu(header.desc_offset);
|
|
|
9ae3a8 |
if (desc_offset) {
|
|
|
9ae3a8 |
return vmdk_open_desc_file(bs, flags, desc_offset << 9);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -728,7 +728,7 @@ next_line:
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
|
|
|
9ae3a8 |
- int64_t desc_offset)
|
|
|
9ae3a8 |
+ uint64_t desc_offset)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
char *buf = NULL;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|