diff mbox

[v1,08/23] memory: provide defaults for MemoryListener operations

Message ID 1349613508-22980-9-git-send-email-avi@redhat.com
State New
Headers show

Commit Message

Avi Kivity Oct. 7, 2012, 12:38 p.m. UTC
Many listeners don't need to respond to all MemoryListener callbacks;
provide suitable defaults instead.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 memory.c | 15 +++++++++++++++
 memory.h | 21 +++++++++++++++++++++
 2 files changed, 36 insertions(+)
diff mbox

Patch

diff --git a/memory.c b/memory.c
index b58b97c..efefcb8 100644
--- a/memory.c
+++ b/memory.c
@@ -1514,6 +1514,21 @@  void memory_listener_unregister(MemoryListener *listener)
     QTAILQ_REMOVE(&memory_listeners, listener, link);
 }
 
+void memory_listener_default_global(MemoryListener *listener)
+{
+}
+
+void memory_listener_default_section(MemoryListener *listener,
+                                     MemoryRegionSection *section)
+{
+}
+
+void memory_listener_default_eventfd(MemoryListener *listener,
+                                     MemoryRegionSection *section,
+                                     bool match_data, uint64_t data, EventNotifier *e)
+{
+}
+
 void address_space_init(AddressSpace *as, MemoryRegion *root)
 {
     memory_region_transaction_begin();
diff --git a/memory.h b/memory.h
index 46bc5e1..0ef95cb 100644
--- a/memory.h
+++ b/memory.h
@@ -223,6 +223,27 @@  struct MemoryListener {
     QTAILQ_ENTRY(MemoryListener) link;
 };
 
+#define MEMORY_LISTENER_DEFAULT_OPS                         \
+    .begin = memory_listener_default_global,                \
+    .commit = memory_listener_default_global,               \
+    .region_add = memory_listener_default_section,          \
+    .region_del = memory_listener_default_section,          \
+    .region_nop = memory_listener_default_section,          \
+    .log_start = memory_listener_default_section,           \
+    .log_stop = memory_listener_default_section,            \
+    .log_sync = memory_listener_default_section,            \
+    .log_global_start = memory_listener_default_global,     \
+    .log_global_stop = memory_listener_default_global,      \
+    .eventfd_add = memory_listener_default_eventfd,         \
+    .eventfd_del = memory_listener_default_eventfd          \
+
+void memory_listener_default_global(MemoryListener *listener);
+void memory_listener_default_section(MemoryListener *listener,
+                                     MemoryRegionSection *section);
+void memory_listener_default_eventfd(MemoryListener *listener,
+                                     MemoryRegionSection *section,
+                                     bool match_data, uint64_t data, EventNotifier *e);
+
 /**
  * memory_region_init: Initialize a memory region
  *