From 2aece63c8a9d2c3a8ff41d2febc4cdeff2633331 Mon Sep 17 00:00:00 2001 From: Xiao Guangrong Date: Wed, 13 Jul 2016 12:18:06 +0800 Subject: hostmem: detect host backend memory is being used properly Currently, we use memory_region_is_mapped() to detect if the host backend memory is being used. This works if the memory is directly mapped into guest's address space, however, it is not true for nvdimm as it uses aliased memory region to map the memory. This is why this bug can happen: https://bugzilla.redhat.com/show_bug.cgi?id=1352769 Fix it by introduce a new filed, is_mapped, to HostMemoryBackend, we set/clear this filed accordingly when the device link/unlink to host backend memory Signed-off-by: Xiao Guangrong Signed-off-by: Paolo Bonzini --- include/sysemu/hostmem.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 4d6617eab7..c903404308 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -53,7 +53,7 @@ struct HostMemoryBackend { /* protected */ uint64_t size; bool merge, dump; - bool prealloc, force_prealloc; + bool prealloc, force_prealloc, is_mapped; DECLARE_BITMAP(host_nodes, MAX_NODES + 1); HostMemPolicy policy; @@ -63,4 +63,6 @@ struct HostMemoryBackend { MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp); +void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped); +bool host_memory_backend_is_mapped(HostMemoryBackend *backend); #endif -- cgit 1.4.1