]> git.proxmox.com Git - qemu.git/commitdiff
exec: move listener from AddressSpaceDispatch to AddressSpace
authorPaolo Bonzini <pbonzini@redhat.com>
Sun, 2 Jun 2013 08:39:07 +0000 (10:39 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Jul 2013 15:42:49 +0000 (17:42 +0200)
This will help having two copies of AddressSpaceDispatch during the
recreation of the radix tree (one being built, and one that is complete
and will be protected by RCU).  We do not want to have to unregister and
re-register the listener.

Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
exec.c
include/exec/memory.h

diff --git a/exec.c b/exec.c
index 598ac3a012882ff00813fb5190b4ec0648b440be..2eb279c41346bda0e80a06f540858d5b0af4246e 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -93,7 +93,6 @@ struct AddressSpaceDispatch {
      * The bottom level has pointers to MemoryRegionSections.
      */
     PhysPageEntry phys_map;
-    MemoryListener listener;
     AddressSpace *as;
 };
 
@@ -841,7 +840,8 @@ static void register_multipage(AddressSpaceDispatch *d,
 
 static void mem_add(MemoryListener *listener, MemoryRegionSection *section)
 {
-    AddressSpaceDispatch *d = container_of(listener, AddressSpaceDispatch, listener);
+    AddressSpace *as = container_of(listener, AddressSpace, dispatch_listener);
+    AddressSpaceDispatch *d = as->dispatch;
     MemoryRegionSection now = *section, remain = *section;
     Int128 page_size = int128_make64(TARGET_PAGE_SIZE);
 
@@ -1703,7 +1703,8 @@ static void io_mem_init(void)
 
 static void mem_begin(MemoryListener *listener)
 {
-    AddressSpaceDispatch *d = container_of(listener, AddressSpaceDispatch, listener);
+    AddressSpace *as = container_of(listener, AddressSpace, dispatch_listener);
+    AddressSpaceDispatch *d = as->dispatch;
 
     d->phys_map.ptr = PHYS_MAP_NODE_NIL;
 }
@@ -1772,22 +1773,22 @@ void address_space_init_dispatch(AddressSpace *as)
     AddressSpaceDispatch *d = g_new(AddressSpaceDispatch, 1);
 
     d->phys_map  = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .is_leaf = 0 };
-    d->listener = (MemoryListener) {
+    d->as = as;
+    as->dispatch = d;
+    as->dispatch_listener = (MemoryListener) {
         .begin = mem_begin,
         .region_add = mem_add,
         .region_nop = mem_add,
         .priority = 0,
     };
-    d->as = as;
-    as->dispatch = d;
-    memory_listener_register(&d->listener, as);
+    memory_listener_register(&as->dispatch_listener, as);
 }
 
 void address_space_destroy_dispatch(AddressSpace *as)
 {
     AddressSpaceDispatch *d = as->dispatch;
 
-    memory_listener_unregister(&d->listener);
+    memory_listener_unregister(&as->dispatch_listener);
     g_free(d);
     as->dispatch = NULL;
 }
index 8355bdb29a91a5a07bdc9c216208b70cb42da59e..248c89bdb64e8c9dd56a65a1c57169b69d34c5e0 100644 (file)
@@ -209,6 +209,8 @@ struct AddressSpace {
     int ioeventfd_nb;
     struct MemoryRegionIoeventfd *ioeventfds;
     struct AddressSpaceDispatch *dispatch;
+    MemoryListener dispatch_listener;
+
     QTAILQ_ENTRY(AddressSpace) address_spaces_link;
 };