From 68363d1c1a0bd0cebb8910fad60772b00b4d3c95 Mon Sep 17 00:00:00 2001 From: Anthony PERARD Date: Thu, 21 Feb 2013 12:16:42 +0000 Subject: [PATCH] exec, memory: Call to xen_modified_memory. This patch add some calls to xen_modified_memory to notify Xen about dirtybits during migration. Backport of e226939de5814527a21396903b08c3d0ed989558 Note a call to xen_modify_memory has been added to qemu_ram_alloc_from_ptr as the upstream version does: cpu_physical_memory_set_dirty_range(new_block->offset, size, 0xff); and this function does not exist in 4.2. Signed-off-by: Anthony PERARD Reviewed-by: Avi Kivity Signed-off-by: Alex Bligh --- exec.c | 4 ++++ memory.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/exec.c b/exec.c index 07a6f6859..fec1b0598 100644 --- a/exec.c +++ b/exec.c @@ -2988,6 +2988,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS), 0xff, size >> TARGET_PAGE_BITS); + if (xen_enabled()) + xen_modified_memory(new_block->offset, size); + if (kvm_enabled()) kvm_setup_guest_memory(new_block->host, size); @@ -3961,6 +3964,7 @@ static void invalidate_and_set_dirty(target_phys_addr_t addr, /* set dirty bit */ cpu_physical_memory_set_dirty_flags(addr, (0xff & ~CODE_DIRTY_FLAG)); } + xen_modified_memory(addr, length); } void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, diff --git a/memory.c b/memory.c index 7c20a0703..6e0c5960f 100644 --- a/memory.c +++ b/memory.c @@ -16,6 +16,7 @@ #include "ioport.h" #include "bitops.h" #include "kvm.h" +#include "hw/xen.h" #include unsigned memory_region_transaction_depth = 0; @@ -1065,6 +1066,9 @@ bool memory_region_get_dirty(MemoryRegion *mr, target_phys_addr_t addr, void memory_region_set_dirty(MemoryRegion *mr, target_phys_addr_t addr) { assert(mr->terminates); + if (xen_enabled()) + xen_modified_memory((mr->ram_addr + addr) & TARGET_PAGE_MASK, + TARGET_PAGE_SIZE); return cpu_physical_memory_set_dirty(mr->ram_addr + addr); } -- 2.39.5