aboutsummaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2012-10-17 20:24:28 +0200
committerJuan Quintela <quintela@redhat.com>2012-12-20 23:09:39 +0100
commit6c279db8ee99e64e498447c67c16e987150be96b (patch)
tree3d8080a95dec3133a71adcc871c58eaf41b68d70 /memory.c
parent5f718a15d0db3775bbcf2755a35dd6b019bcff8b (diff)
memory: introduce memory_region_test_and_clear_dirty
This function avoids having to do two calls, one to test the dirty bit, and other to reset it. Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/memory.c b/memory.c
index 35e6122dd7..410c5f80b4 100644
--- a/memory.c
+++ b/memory.c
@@ -1081,6 +1081,22 @@ void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr,
return cpu_physical_memory_set_dirty_range(mr->ram_addr + addr, size, -1);
}
+bool memory_region_test_and_clear_dirty(MemoryRegion *mr, hwaddr addr,
+ hwaddr size, unsigned client)
+{
+ bool ret;
+ assert(mr->terminates);
+ ret = cpu_physical_memory_get_dirty(mr->ram_addr + addr, size,
+ 1 << client);
+ if (ret) {
+ cpu_physical_memory_reset_dirty(mr->ram_addr + addr,
+ mr->ram_addr + addr + size,
+ 1 << client);
+ }
+ return ret;
+}
+
+
void memory_region_sync_dirty_bitmap(MemoryRegion *mr)
{
AddressSpace *as;