summaryrefslogtreecommitdiff
path: root/qemu/block-qcow2.c
diff options
context:
space:
mode:
authorbellard <bellard>2006-08-05 22:24:28 +0000
committerbellard <bellard>2006-08-05 22:24:28 +0000
commit501d4ad53c46a2a28e8e3d1d7519aa592e7419b1 (patch)
tree8168ee1ae2d811d6b7a6028f1e47c77ef39b1f91 /qemu/block-qcow2.c
parent57f38b959c9f2c7ef914c5b2cd334d5f55ec333d (diff)
fixed disk image creation
Diffstat (limited to 'qemu/block-qcow2.c')
-rw-r--r--qemu/block-qcow2.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c
index f499b13b..7d92ca96 100644
--- a/qemu/block-qcow2.c
+++ b/qemu/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);