aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-05 22:24:28 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-05 22:24:28 +0000
commit15e6690aca348a7dc8772b8f1197cf13c8764335 (patch)
treed461b2a971bcad649a43c3ada4f218572ea0ddf2
parentc47c33b098302d2c94db22e76ef5745aab05a7c8 (diff)
fixed disk image creation
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2089 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--block-qcow2.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/block-qcow2.c b/block-qcow2.c
index f499b13be1..7d92ca9620 100644
--- a/block-qcow2.c
+++ b/block-qcow2.c
@@ -1081,7 +1081,7 @@ static int qcow_create(const char *filename, int64_t total_size,
s->l1_table_offset = offset;
header.l1_table_offset = cpu_to_be64(s->l1_table_offset);
header.l1_size = cpu_to_be32(l1_size);
- offset += align_offset(l1_size, s->cluster_size);
+ offset += align_offset(l1_size * sizeof(uint64_t), s->cluster_size);
s->refcount_table = qemu_mallocz(s->cluster_size);
if (!s->refcount_table)
@@ -1089,7 +1089,7 @@ static int qcow_create(const char *filename, int64_t total_size,
s->refcount_block = qemu_mallocz(s->cluster_size);
if (!s->refcount_block)
goto fail;
-
+
s->refcount_table_offset = offset;
header.refcount_table_offset = cpu_to_be64(offset);
header.refcount_table_clusters = cpu_to_be32(1);
@@ -1101,7 +1101,7 @@ static int qcow_create(const char *filename, int64_t total_size,
/* update refcounts */
create_refcount_update(s, 0, header_size);
- create_refcount_update(s, s->l1_table_offset, l1_size);
+ create_refcount_update(s, s->l1_table_offset, l1_size * sizeof(uint64_t));
create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
create_refcount_update(s, s->refcount_block_offset, s->cluster_size);
@@ -1894,7 +1894,11 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size)
if (min_size <= new_table_size)
break;
}
-
+#ifdef DEBUG_ALLOC2
+ printf("grow_refcount_table from %d to %d\n",
+ s->refcount_table_size,
+ new_table_size);
+#endif
new_table_size2 = new_table_size * sizeof(uint64_t);
new_table = qemu_mallocz(new_table_size2);
if (!new_table)
@@ -2144,7 +2148,7 @@ static void check_refcounts(BlockDriverState *bs)
size = bdrv_getlength(s->hd);
nb_clusters = (size + s->cluster_size - 1) >> s->cluster_bits;
refcount_table = qemu_mallocz(nb_clusters * sizeof(uint16_t));
-
+
/* header */
inc_refcounts(bs, refcount_table, nb_clusters,
0, s->cluster_size);