thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-dmg-use-uint64_t-consistently-for-sectors-and-length.patch

0a122b
From dbcfb970e94adbf251dadb900128d576a7e0a737 Mon Sep 17 00:00:00 2001
0a122b
From: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Date: Tue, 25 Mar 2014 14:23:45 +0100
0a122b
Subject: [PATCH 38/49] dmg: use uint64_t consistently for sectors and lengths
0a122b
0a122b
RH-Author: Kevin Wolf <kwolf@redhat.com>
0a122b
Message-id: <1395753835-7591-39-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: n/a
0a122b
O-Subject: [virt-devel] [EMBARGOED RHEL-7.0 qemu-kvm PATCH 38/48] dmg: use uint64_t consistently for sectors and lengths
0a122b
Bugzilla: 1066691
0a122b
RH-Acked-by: Jeff Cody <jcody@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
0a122b
From: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1066691
0a122b
Upstream status: Series embargoed
0a122b
0a122b
The DMG metadata is stored as uint64_t, so use the same type for
0a122b
sector_num. int was a particularly poor choice since it is only 32-bit
0a122b
and would truncate large values.
0a122b
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 block/dmg.c |    6 +++---
0a122b
 1 files changed, 3 insertions(+), 3 deletions(-)
0a122b
0a122b
diff --git a/block/dmg.c b/block/dmg.c
0a122b
index ad253fe..be0ee33 100644
0a122b
--- a/block/dmg.c
0a122b
+++ b/block/dmg.c
0a122b
@@ -281,7 +281,7 @@ fail:
0a122b
 }
0a122b
 
0a122b
 static inline int is_sector_in_chunk(BDRVDMGState* s,
0a122b
-                uint32_t chunk_num, int sector_num)
0a122b
+                uint32_t chunk_num, uint64_t sector_num)
0a122b
 {
0a122b
     if (chunk_num >= s->n_chunks || s->sectors[chunk_num] > sector_num ||
0a122b
             s->sectors[chunk_num] + s->sectorcounts[chunk_num] <= sector_num) {
0a122b
@@ -291,7 +291,7 @@ static inline int is_sector_in_chunk(BDRVDMGState* s,
0a122b
     }
0a122b
 }
0a122b
 
0a122b
-static inline uint32_t search_chunk(BDRVDMGState *s, int sector_num)
0a122b
+static inline uint32_t search_chunk(BDRVDMGState *s, uint64_t sector_num)
0a122b
 {
0a122b
     /* binary search */
0a122b
     uint32_t chunk1 = 0, chunk2 = s->n_chunks, chunk3;
0a122b
@@ -308,7 +308,7 @@ static inline uint32_t search_chunk(BDRVDMGState *s, int sector_num)
0a122b
     return s->n_chunks; /* error */
0a122b
 }
0a122b
 
0a122b
-static inline int dmg_read_chunk(BlockDriverState *bs, int sector_num)
0a122b
+static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num)
0a122b
 {
0a122b
     BDRVDMGState *s = bs->opaque;
0a122b
 
0a122b
-- 
0a122b
1.7.1
0a122b