summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Rogers <brogers@novell.com>2009-09-23 16:13:18 -0600
committerMarcelo Tosatti <mtosatti@redhat.com>2009-09-28 13:30:58 -0300
commit692d9aca97b865b0f7903565274a52606910f129 (patch)
treea787ad1feb3fc3349594577289e0aa20daeb155a /qemu-kvm.c
parentFix segfault on -no-kvm startup (diff)
downloadqemu-kvm-692d9aca97b865b0f7903565274a52606910f129.tar.gz
qemu-kvm-692d9aca97b865b0f7903565274a52606910f129.tar.bz2
qemu-kvm-692d9aca97b865b0f7903565274a52606910f129.zip
qemu-kvm: allocate correct size for dirty bitmap
The dirty bitmap copied out to userspace is stored in a long array, and gets copied out to userspace accordingly. This patch accounts for that correctly. Currently I'm seeing kvm crashing due to writing beyond the end of the alloc'd dirty bitmap memory, because the buffer has the wrong size. Signed-off-by: Bruce Rogers Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'qemu-kvm.c')
-rw-r--r--qemu-kvm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 5effc255f..22d473c8b 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -701,7 +701,7 @@ int kvm_get_dirty_pages_range(kvm_context_t kvm, unsigned long phys_addr,
for (i = 0; i < KVM_MAX_NUM_MEM_REGIONS; ++i) {
if ((slots[i].len && (uint64_t) slots[i].phys_addr >= phys_addr)
&& ((uint64_t) slots[i].phys_addr + slots[i].len <= end_addr)) {
- buf = qemu_malloc((slots[i].len / 4096 + 7) / 8 + 2);
+ buf = qemu_malloc(BITMAP_SIZE(slots[i].len));
r = kvm_get_map(kvm, KVM_GET_DIRTY_LOG, i, buf);
if (r) {
qemu_free(buf);