]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
kvm: fix incorrect length in a loop over kvm dirty pages map
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 19 Nov 2012 15:40:47 +0000 (15:40 +0000)
committerAlexander Graf <agraf@suse.de>
Mon, 26 Nov 2012 18:53:26 +0000 (19:53 +0100)
QEMU allocates a map enough for 4k pages. However the system page size
can be 64K (for example on POWER) and the host kernel uses only a small
part of it as one big stores a dirty flag for 16 pages 4K each,
the hpratio variable stores this ratio and
the kvm_get_dirty_pages_log_range function handles it correctly.

However kvm_get_dirty_pages_log_range still goes beyond the data
provided by the host kernel which is not correct. It does not cause
errors at the moment as the whole bitmap is zeroed before doing KVM ioctl.

The patch reduces number of iterations over the map.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alexander Graf <agraf@suse.de>
kvm-all.c

index 3bc3347d07192b5c2a50c16ec987de7d72107fc2..8e9a8d8fd2ce148b64588753de993aac6468b309 100644 (file)
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -364,7 +364,7 @@ static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section,
     unsigned int i, j;
     unsigned long page_number, c;
     hwaddr addr, addr1;
-    unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 1) / HOST_LONG_BITS;
+    unsigned int len = ((section->size / getpagesize()) + HOST_LONG_BITS - 1) / HOST_LONG_BITS;
     unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE;
 
     /*