[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V7 01/29] memory: qemu_check_ram_volatile
From: |
Steve Sistare |
Subject: |
[PATCH V7 01/29] memory: qemu_check_ram_volatile |
Date: |
Wed, 22 Dec 2021 11:05:06 -0800 |
Add a function that returns an error 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 | 26 ++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 20f1b27..137f5f3 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2981,6 +2981,14 @@ bool ram_block_discard_is_disabled(void);
*/
bool ram_block_discard_is_required(void);
+/**
+ * qemu_ram_check_volatile: return 1 if any memory regions are writable and not
+ * backed by shared memory, else return 0.
+ *
+ * @errp: returned error message identifying the first volatile region found.
+ */
+int qemu_check_ram_volatile(Error **errp);
+
#endif
#endif
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 7340e19..30b2f68 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2837,6 +2837,32 @@ void memory_global_dirty_log_stop(unsigned int flags)
memory_global_dirty_log_do_stop(flags);
}
+static int check_volatile(RAMBlock *rb, void *opaque)
+{
+ MemoryRegion *mr = rb->mr;
+
+ if (mr &&
+ memory_region_is_ram(mr) &&
+ !memory_region_is_ram_device(mr) &&
+ !memory_region_is_rom(mr) &&
+ (rb->fd == -1 || !qemu_ram_is_shared(rb))) {
+ *(const char **)opaque = memory_region_name(mr);
+ return -1;
+ }
+ return 0;
+}
+
+int qemu_check_ram_volatile(Error **errp)
+{
+ char *name;
+
+ if (qemu_ram_foreach_block(check_volatile, &name)) {
+ error_setg(errp, "Memory region %s is volatile", name);
+ return -1;
+ }
+ return 0;
+}
+
static void listener_add_address_space(MemoryListener *listener,
AddressSpace *as)
{
--
1.8.3.1
- [PATCH V7 00/29] Live Update, Steve Sistare, 2021/12/22
- [PATCH V7 02/29] migration: fix populate_vfio_info, Steve Sistare, 2021/12/22
- [PATCH V7 06/29] cpr: reboot mode, Steve Sistare, 2021/12/22
- [PATCH V7 11/29] qapi: list utility functions, Steve Sistare, 2021/12/22
- [PATCH V7 09/29] oslib: qemu_clear_cloexec, Steve Sistare, 2021/12/22
- [PATCH V7 12/29] vl: helper to request re-exec, Steve Sistare, 2021/12/22
- [PATCH V7 03/29] migration: qemu file wrappers, Steve Sistare, 2021/12/22
- [PATCH V7 07/29] cpr: reboot HMP interfaces, Steve Sistare, 2021/12/22
- [PATCH V7 05/29] vl: start on wakeup request, Steve Sistare, 2021/12/22
- [PATCH V7 01/29] memory: qemu_check_ram_volatile,
Steve Sistare <=
- [PATCH V7 04/29] migration: simplify savevm, Steve Sistare, 2021/12/22
- [PATCH V7 13/29] cpr: preserve extra state, Steve Sistare, 2021/12/22
- [PATCH V7 15/29] cpr: restart HMP interfaces, Steve Sistare, 2021/12/22
- [PATCH V7 17/29] pci: export functions for cpr, Steve Sistare, 2021/12/22
- [PATCH V7 20/29] vfio-pci: cpr part 2 (msi), Steve Sistare, 2021/12/22
- [PATCH V7 19/29] vfio-pci: cpr part 1 (fd and dma), Steve Sistare, 2021/12/22
- [PATCH V7 16/29] hostmem-memfd: cpr for memory-backend-memfd, Steve Sistare, 2021/12/22
- [PATCH V7 14/29] cpr: restart mode, Steve Sistare, 2021/12/22