memory: support stateless memory listeners
Current memory listeners are incremental; that is, they are expected to
maintain their own state, and receive callbacks for changes to that state.
This patch adds support for stateless listeners; these work by receiving
a ->begin() callback (which tells them that new state is coming), a
sequence of ->region_add() and ->region_nop() callbacks, and then a
->commit() callback which signifies the end of the new state. They should
ignore ->region_del() callbacks.
Signed-off-by: Avi Kivity <avi@redhat.com>
diff --git a/exec.c b/exec.c
index 16973a6..6726afd 100644
--- a/exec.c
+++ b/exec.c
@@ -3488,6 +3488,14 @@
"watch", UINT64_MAX);
}
+static void core_begin(MemoryListener *listener)
+{
+}
+
+static void core_commit(MemoryListener *listener)
+{
+}
+
static void core_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
@@ -3500,6 +3508,11 @@
cpu_register_physical_memory_log(section, false);
}
+static void core_region_nop(MemoryListener *listener,
+ MemoryRegionSection *section)
+{
+}
+
static void core_log_start(MemoryListener *listener,
MemoryRegionSection *section)
{
@@ -3537,6 +3550,14 @@
{
}
+static void io_begin(MemoryListener *listener)
+{
+}
+
+static void io_commit(MemoryListener *listener)
+{
+}
+
static void io_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
@@ -3551,6 +3572,11 @@
isa_unassign_ioport(section->offset_within_address_space, section->size);
}
+static void io_region_nop(MemoryListener *listener,
+ MemoryRegionSection *section)
+{
+}
+
static void io_log_start(MemoryListener *listener,
MemoryRegionSection *section)
{
@@ -3587,8 +3613,11 @@
}
static MemoryListener core_memory_listener = {
+ .begin = core_begin,
+ .commit = core_commit,
.region_add = core_region_add,
.region_del = core_region_del,
+ .region_nop = core_region_nop,
.log_start = core_log_start,
.log_stop = core_log_stop,
.log_sync = core_log_sync,
@@ -3600,8 +3629,11 @@
};
static MemoryListener io_memory_listener = {
+ .begin = io_begin,
+ .commit = io_commit,
.region_add = io_region_add,
.region_del = io_region_del,
+ .region_nop = io_region_nop,
.log_start = io_log_start,
.log_stop = io_log_stop,
.log_sync = io_log_sync,