[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V4 01/25] qemu_ram_volatile
From: |
Steve Sistare |
Subject: |
[PATCH V4 01/25] qemu_ram_volatile |
Date: |
Tue, 6 Jul 2021 09:45:32 -0700 |
Add a function that returns true if any ram_list block represents
volatile memory.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/exec/memory.h | 8 ++++++++
softmmu/memory.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 5728a68..e8b71d8 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2629,6 +2629,14 @@ bool ram_block_discard_is_disabled(void);
*/
bool ram_block_discard_is_required(void);
+/**
+ * qemu_ram_volatile: return true if any memory regions are writable and not
+ * backed by shared memory.
+ *
+ * @errp: returned error message identifying the bad region.
+ */
+bool qemu_ram_volatile(Error **errp);
+
#endif
#endif
diff --git a/softmmu/memory.c b/softmmu/memory.c
index d4493ef..7197559 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2707,6 +2707,36 @@ void memory_global_dirty_log_stop(void)
memory_global_dirty_log_do_stop();
}
+/*
+ * Return true if any memory regions are writable and not backed by shared
+ * memory.
+ */
+bool qemu_ram_volatile(Error **errp)
+{
+ RAMBlock *block;
+ MemoryRegion *mr;
+ bool ret = false;
+
+ rcu_read_lock();
+ QLIST_FOREACH_RCU(block, &ram_list.blocks, next) {
+ mr = block->mr;
+ if (mr &&
+ memory_region_is_ram(mr) &&
+ !memory_region_is_ram_device(mr) &&
+ !memory_region_is_rom(mr) &&
+ (block->fd == -1 || !qemu_ram_is_shared(block))) {
+
+ error_setg(errp, "Memory region %s is volatile",
+ memory_region_name(mr));
+ ret = true;
+ break;
+ }
+ }
+
+ rcu_read_unlock();
+ return ret;
+}
+
static void listener_add_address_space(MemoryListener *listener,
AddressSpace *as)
{
--
1.8.3.1
- [PATCH V4 00/25] Live Update, Steve Sistare, 2021/07/06
- [PATCH V4 01/25] qemu_ram_volatile,
Steve Sistare <=
- [PATCH V4 02/25] cpr: reboot mode, Steve Sistare, 2021/07/06
- [PATCH V4 05/25] as_flat_walk, Steve Sistare, 2021/07/06
- [PATCH V4 03/25] cpr: QMP interfaces for reboot, Steve Sistare, 2021/07/06
- [PATCH V4 06/25] oslib: qemu_clr_cloexec, Steve Sistare, 2021/07/06
- [PATCH V4 07/25] machine: memfd-alloc option, Steve Sistare, 2021/07/06
- [PATCH V4 08/25] vl: add helper to request re-exec, Steve Sistare, 2021/07/06
- [PATCH V4 09/25] string to strList, Steve Sistare, 2021/07/06
- [PATCH V4 10/25] util: env var helpers, Steve Sistare, 2021/07/06
- [PATCH V4 12/25] cpr: QMP interfaces for restart, Steve Sistare, 2021/07/06
- [PATCH V4 11/25] cpr: restart mode, Steve Sistare, 2021/07/06