Add an helper to change the priority of a memory region at runtime. Suggested-by: Alexey Kardashevskiy <a...@ozlabs.ru> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- include/exec/memory.h | 10 ++++++++++ softmmu/memory.c | 11 +++++++++++ 2 files changed, 21 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h index 5728a681b27..6ad9ff83457 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1983,6 +1983,16 @@ void memory_region_set_size(MemoryRegion *mr, uint64_t size); void memory_region_set_alias_offset(MemoryRegion *mr, hwaddr offset); +/** + * memory_region_set_priority: dynamically update the priority of a region. + * + * Dynamically updates the priority of a region. + * + * @mr: the #MemoryRegion to be updated. + * @priority: priority of the region. + */ +void memory_region_set_priority(MemoryRegion *mr, int priority); + /** * memory_region_present: checks if an address relative to a @container * translates into #MemoryRegion within @container diff --git a/softmmu/memory.c b/softmmu/memory.c index 4fbeee02dc7..fdba938f299 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2504,6 +2504,17 @@ void memory_region_set_size(MemoryRegion *mr, uint64_t size) memory_region_transaction_commit(); } +void memory_region_set_priority(MemoryRegion *mr, int priority) +{ + if (priority == mr->priority) { + return; + } + memory_region_transaction_begin(); + mr->priority = priority; + memory_region_update_pending = true; + memory_region_transaction_commit(); +} + static void memory_region_readd_subregion(MemoryRegion *mr) { MemoryRegion *container = mr->container; -- 2.26.2