summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2009-07-07 18:09:42 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-10 13:44:29 -0500
commit3f6a3ee51ebd1e86c48ff1216f5caf9785913ab5 (patch)
treead855afc990fe0a4fd24c9c7082821649c3e48fc /block/qcow2-cluster.c
parentqcow1: Fix qcow_aio_writev (diff)
downloadqemu-kvm-3f6a3ee51ebd1e86c48ff1216f5caf9785913ab5.tar.gz
qemu-kvm-3f6a3ee51ebd1e86c48ff1216f5caf9785913ab5.tar.bz2
qemu-kvm-3f6a3ee51ebd1e86c48ff1216f5caf9785913ab5.zip
qcow2: Fix L1 table memory allocation
Contrary to what one could expect, the size of L1 tables is not cluster aligned. So as we're writing whole sectors now instead of single entries, we need to ensure that the L1 table in memory is large enough; otherwise write would access memory after the end of the L1 table. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block/qcow2-cluster.c')
-rw-r--r--block/qcow2-cluster.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index d349655d0..057dac573 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -47,7 +47,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size)
#endif
new_l1_size2 = sizeof(uint64_t) * new_l1_size;
- new_l1_table = qemu_mallocz(new_l1_size2);
+ new_l1_table = qemu_mallocz(align_offset(new_l1_size2, 512));
memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
/* write new table (align to cluster) */