Blame SOURCES/kvm-qcow2-Fix-types-in-qcow2_alloc_clusters-and-alloc_cl.patch

0a122b
From e1547d9eea752dde38bee613afb5cfb7bb26f0f8 Mon Sep 17 00:00:00 2001
0a122b
From: Kevin Wolf <kwolf@redhat.com>
0a122b
Date: Tue, 25 Mar 2014 14:23:37 +0100
0a122b
Subject: [PATCH 30/49] qcow2: Fix types in qcow2_alloc_clusters and alloc_clusters_noref
0a122b
0a122b
RH-Author: Kevin Wolf <kwolf@redhat.com>
0a122b
Message-id: <1395753835-7591-31-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: n/a
0a122b
O-Subject: [virt-devel] [EMBARGOED RHEL-7.0 qemu-kvm PATCH 30/48] qcow2: Fix types in qcow2_alloc_clusters and alloc_clusters_noref
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
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1066691
0a122b
Upstream status: Series embargoed
0a122b
0a122b
In order to avoid integer overflows.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 block/qcow2-refcount.c |   11 ++++++-----
0a122b
 block/qcow2.h          |    6 +++---
0a122b
 2 files changed, 9 insertions(+), 8 deletions(-)
0a122b
0a122b
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
0a122b
index 7b00dda..fb57c10 100644
0a122b
--- a/block/qcow2-refcount.c
0a122b
+++ b/block/qcow2-refcount.c
0a122b
@@ -28,7 +28,7 @@
0a122b
 #include "qemu/range.h"
0a122b
 #include "qapi/qmp/types.h"
0a122b
 
0a122b
-static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size);
0a122b
+static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size);
0a122b
 static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
0a122b
                             int64_t offset, int64_t length,
0a122b
                             int addend, enum qcow2_discard_type type);
0a122b
@@ -634,15 +634,16 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs,
0a122b
 
0a122b
 
0a122b
 /* return < 0 if error */
0a122b
-static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size)
0a122b
+static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size)
0a122b
 {
0a122b
     BDRVQcowState *s = bs->opaque;
0a122b
-    int i, nb_clusters, refcount;
0a122b
+    uint64_t i, nb_clusters;
0a122b
+    int refcount;
0a122b
 
0a122b
     nb_clusters = size_to_clusters(s, size);
0a122b
 retry:
0a122b
     for(i = 0; i < nb_clusters; i++) {
0a122b
-        int64_t next_cluster_index = s->free_cluster_index++;
0a122b
+        uint64_t next_cluster_index = s->free_cluster_index++;
0a122b
         refcount = get_refcount(bs, next_cluster_index);
0a122b
 
0a122b
         if (refcount < 0) {
0a122b
@@ -659,7 +660,7 @@ retry:
0a122b
     return (s->free_cluster_index - nb_clusters) << s->cluster_bits;
0a122b
 }
0a122b
 
0a122b
-int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size)
0a122b
+int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size)
0a122b
 {
0a122b
     int64_t offset;
0a122b
     int ret;
0a122b
diff --git a/block/qcow2.h b/block/qcow2.h
0a122b
index 0173d95..9f9f5ae 100644
0a122b
--- a/block/qcow2.h
0a122b
+++ b/block/qcow2.h
0a122b
@@ -222,8 +222,8 @@ typedef struct BDRVQcowState {
0a122b
     uint64_t *refcount_table;
0a122b
     uint64_t refcount_table_offset;
0a122b
     uint32_t refcount_table_size;
0a122b
-    int64_t free_cluster_index;
0a122b
-    int64_t free_byte_offset;
0a122b
+    uint64_t free_cluster_index;
0a122b
+    uint64_t free_byte_offset;
0a122b
 
0a122b
     CoMutex lock;
0a122b
 
0a122b
@@ -462,7 +462,7 @@ void qcow2_refcount_close(BlockDriverState *bs);
0a122b
 int qcow2_update_cluster_refcount(BlockDriverState *bs, int64_t cluster_index,
0a122b
                                   int addend, enum qcow2_discard_type type);
0a122b
 
0a122b
-int64_t qcow2_alloc_clusters(BlockDriverState *bs, int64_t size);
0a122b
+int64_t qcow2_alloc_clusters(BlockDriverState *bs, uint64_t size);
0a122b
 int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset,
0a122b
     int nb_clusters);
0a122b
 int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size);
0a122b
-- 
0a122b
1.7.1
0a122b