From 1551573acca94888a425ee4dc967ab58ae2c5bed Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 13 Feb 2018 08:41:40 -0500 Subject: [PATCH] memory: differentiate memory_region_is_logging and memory_region_get_dirty_log_mask For now memory regions only track DIRTY_MEMORY_VGA individually, but this will change soon. To support this, split memory_region_is_logging in two functions: one that returns a given bit from dirty_log_mask, and one that returns the entire mask. memory_region_is_logging gets an extra parameter so that the compiler flags misuse. While VGA-specific users (including the Xen listener!) will want to keep checking that bit, KVM and vhost check for "any bit except migration" (because migration is handled via the global start/stop listener callbacks). Backports commit 2d1a35bef0ed96b3f23535e459c552414ccdbafd from qemu --- qemu/aarch64.h | 1 + qemu/aarch64eb.h | 1 + qemu/arm.h | 1 + qemu/armeb.h | 1 + qemu/header_gen.py | 1 + qemu/include/exec/memory.h | 14 +++++++++++++- qemu/m68k.h | 1 + qemu/memory.c | 7 ++++++- qemu/mips.h | 1 + qemu/mips64.h | 1 + qemu/mips64el.h | 1 + qemu/mipsel.h | 1 + qemu/powerpc.h | 1 + qemu/sparc.h | 1 + qemu/sparc64.h | 1 + qemu/x86_64.h | 1 + 16 files changed, 33 insertions(+), 2 deletions(-) diff --git a/qemu/aarch64.h b/qemu/aarch64.h index 1b33e379..cedd35ef 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_aarch64 #define memory_region_get_alignment memory_region_get_alignment_aarch64 #define memory_region_get_container memory_region_get_container_aarch64 +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_aarch64 #define memory_region_get_fd memory_region_get_fd_aarch64 #define memory_region_get_may_overlap memory_region_get_may_overlap_aarch64 #define memory_region_get_priority memory_region_get_priority_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index 1a5814b1..226530bf 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_aarch64eb #define memory_region_get_alignment memory_region_get_alignment_aarch64eb #define memory_region_get_container memory_region_get_container_aarch64eb +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_aarch64eb #define memory_region_get_fd memory_region_get_fd_aarch64eb #define memory_region_get_may_overlap memory_region_get_may_overlap_aarch64eb #define memory_region_get_priority memory_region_get_priority_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index a2d111bd..bf5d12ac 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_arm #define memory_region_get_alignment memory_region_get_alignment_arm #define memory_region_get_container memory_region_get_container_arm +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_arm #define memory_region_get_fd memory_region_get_fd_arm #define memory_region_get_may_overlap memory_region_get_may_overlap_arm #define memory_region_get_priority memory_region_get_priority_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index a0e8a14f..13cf78f0 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_armeb #define memory_region_get_alignment memory_region_get_alignment_armeb #define memory_region_get_container memory_region_get_container_armeb +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_armeb #define memory_region_get_fd memory_region_get_fd_armeb #define memory_region_get_may_overlap memory_region_get_may_overlap_armeb #define memory_region_get_priority memory_region_get_priority_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index c52d0664..ec13f412 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -2061,6 +2061,7 @@ symbols = ( 'memory_region_get_addr', 'memory_region_get_alignment', 'memory_region_get_container', + 'memory_region_get_dirty_log_mask', 'memory_region_get_fd', 'memory_region_get_may_overlap', 'memory_region_get_priority', diff --git a/qemu/include/exec/memory.h b/qemu/include/exec/memory.h index 8e4e975c..e72e7102 100644 --- a/qemu/include/exec/memory.h +++ b/qemu/include/exec/memory.h @@ -512,8 +512,20 @@ const char *memory_region_name(const MemoryRegion *mr); * Returns %true if the memory region is logging writes * * @mr: the memory region being queried + * @client: the client being queried */ -bool memory_region_is_logging(MemoryRegion *mr); +bool memory_region_is_logging(MemoryRegion *mr, uint8_t client); + +/** + * memory_region_get_dirty_log_mask: return the clients for which a + * memory region is logging writes. + * + * Returns a bitmap of clients, which right now will be either 0 or + * (1 << DIRTY_MEMORY_VGA). + * + * @mr: the memory region being queried + */ +uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr); /** * memory_region_is_rom: check whether a memory region is ROM diff --git a/qemu/m68k.h b/qemu/m68k.h index f4c94daa..db9769b4 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_m68k #define memory_region_get_alignment memory_region_get_alignment_m68k #define memory_region_get_container memory_region_get_container_m68k +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_m68k #define memory_region_get_fd memory_region_get_fd_m68k #define memory_region_get_may_overlap memory_region_get_may_overlap_m68k #define memory_region_get_priority memory_region_get_priority_m68k diff --git a/qemu/memory.c b/qemu/memory.c index 6327e4e2..123f6564 100644 --- a/qemu/memory.c +++ b/qemu/memory.c @@ -1269,11 +1269,16 @@ bool memory_region_is_skip_dump(MemoryRegion *mr) return mr->skip_dump; } -bool memory_region_is_logging(MemoryRegion *mr) +uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) { return mr->dirty_log_mask; } +bool memory_region_is_logging(MemoryRegion *mr, uint8_t client) +{ + return memory_region_get_dirty_log_mask(mr) & (1 << client); +} + bool memory_region_is_rom(MemoryRegion *mr) { return mr->ram && mr->readonly; diff --git a/qemu/mips.h b/qemu/mips.h index 8d30d14f..45670ccb 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_mips #define memory_region_get_alignment memory_region_get_alignment_mips #define memory_region_get_container memory_region_get_container_mips +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_mips #define memory_region_get_fd memory_region_get_fd_mips #define memory_region_get_may_overlap memory_region_get_may_overlap_mips #define memory_region_get_priority memory_region_get_priority_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index da300260..5a35620b 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_mips64 #define memory_region_get_alignment memory_region_get_alignment_mips64 #define memory_region_get_container memory_region_get_container_mips64 +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_mips64 #define memory_region_get_fd memory_region_get_fd_mips64 #define memory_region_get_may_overlap memory_region_get_may_overlap_mips64 #define memory_region_get_priority memory_region_get_priority_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index 6218b8d9..beb96cbe 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_mips64el #define memory_region_get_alignment memory_region_get_alignment_mips64el #define memory_region_get_container memory_region_get_container_mips64el +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_mips64el #define memory_region_get_fd memory_region_get_fd_mips64el #define memory_region_get_may_overlap memory_region_get_may_overlap_mips64el #define memory_region_get_priority memory_region_get_priority_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index 57f30b22..1ed2b848 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_mipsel #define memory_region_get_alignment memory_region_get_alignment_mipsel #define memory_region_get_container memory_region_get_container_mipsel +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_mipsel #define memory_region_get_fd memory_region_get_fd_mipsel #define memory_region_get_may_overlap memory_region_get_may_overlap_mipsel #define memory_region_get_priority memory_region_get_priority_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index 7824092a..dfc35c3b 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_powerpc #define memory_region_get_alignment memory_region_get_alignment_powerpc #define memory_region_get_container memory_region_get_container_powerpc +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_powerpc #define memory_region_get_fd memory_region_get_fd_powerpc #define memory_region_get_may_overlap memory_region_get_may_overlap_powerpc #define memory_region_get_priority memory_region_get_priority_powerpc diff --git a/qemu/sparc.h b/qemu/sparc.h index e55500d0..a1a2e0ac 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_sparc #define memory_region_get_alignment memory_region_get_alignment_sparc #define memory_region_get_container memory_region_get_container_sparc +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_sparc #define memory_region_get_fd memory_region_get_fd_sparc #define memory_region_get_may_overlap memory_region_get_may_overlap_sparc #define memory_region_get_priority memory_region_get_priority_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 9befb684..959778ea 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_sparc64 #define memory_region_get_alignment memory_region_get_alignment_sparc64 #define memory_region_get_container memory_region_get_container_sparc64 +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_sparc64 #define memory_region_get_fd memory_region_get_fd_sparc64 #define memory_region_get_may_overlap memory_region_get_may_overlap_sparc64 #define memory_region_get_priority memory_region_get_priority_sparc64 diff --git a/qemu/x86_64.h b/qemu/x86_64.h index eae59735..398fd147 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -2055,6 +2055,7 @@ #define memory_region_get_addr memory_region_get_addr_x86_64 #define memory_region_get_alignment memory_region_get_alignment_x86_64 #define memory_region_get_container memory_region_get_container_x86_64 +#define memory_region_get_dirty_log_mask memory_region_get_dirty_log_mask_x86_64 #define memory_region_get_fd memory_region_get_fd_x86_64 #define memory_region_get_may_overlap memory_region_get_may_overlap_x86_64 #define memory_region_get_priority memory_region_get_priority_x86_64