Commit bd8367761236cd5c435598aeb2f1b8240c09b059

Authored by Alexander Graf
Committed by Anthony Liguori
1 parent 16415335

Fake dirty loggin when it's not there

Some KVM platforms don't support dirty logging yet, like IA64 and PPC,
so in order to still have screen updates on those, we need to fake it.

This patch just tells the getter function for dirty bitmaps, that all
pages within a slot are dirty when the slot has dirty logging enabled.

That way we can implement dirty logging on those platforms sometime when
it drags down performance, but share the rest of the code with dirty
logging capable platforms.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 1 changed file with 12 additions and 1 deletions
kvm-all.c
@@ -300,6 +300,7 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, @@ -300,6 +300,7 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
300 KVMDirtyLog d; 300 KVMDirtyLog d;
301 KVMSlot *mem; 301 KVMSlot *mem;
302 int ret = 0; 302 int ret = 0;
  303 + int r;
303 304
304 d.dirty_bitmap = NULL; 305 d.dirty_bitmap = NULL;
305 while (start_addr < end_addr) { 306 while (start_addr < end_addr) {
@@ -308,6 +309,11 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, @@ -308,6 +309,11 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
308 break; 309 break;
309 } 310 }
310 311
  312 + /* We didn't activate dirty logging? Don't care then. */
  313 + if(!(mem->flags & KVM_MEM_LOG_DIRTY_PAGES)) {
  314 + continue;
  315 + }
  316 +
311 size = ((mem->memory_size >> TARGET_PAGE_BITS) + 7) / 8; 317 size = ((mem->memory_size >> TARGET_PAGE_BITS) + 7) / 8;
312 if (!d.dirty_bitmap) { 318 if (!d.dirty_bitmap) {
313 d.dirty_bitmap = qemu_malloc(size); 319 d.dirty_bitmap = qemu_malloc(size);
@@ -319,7 +325,8 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, @@ -319,7 +325,8 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
319 325
320 d.slot = mem->slot; 326 d.slot = mem->slot;
321 327
322 - if (kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d) == -1) { 328 + r = kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d);
  329 + if (r == -EINVAL) {
323 dprintf("ioctl failed %d\n", errno); 330 dprintf("ioctl failed %d\n", errno);
324 ret = -1; 331 ret = -1;
325 break; 332 break;
@@ -335,6 +342,10 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, @@ -335,6 +342,10 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
335 342
336 if ((bitmap[word] >> bit) & 1) { 343 if ((bitmap[word] >> bit) & 1) {
337 cpu_physical_memory_set_dirty(addr); 344 cpu_physical_memory_set_dirty(addr);
  345 + } else if (r < 0) {
  346 + /* When our KVM implementation doesn't know about dirty logging
  347 + * we can just assume it's always dirty and be fine. */
  348 + cpu_physical_memory_set_dirty(addr);
338 } 349 }
339 } 350 }
340 start_addr = phys_addr; 351 start_addr = phys_addr;