[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V2 02/22] qemu_ram_volatile
From: |
Steve Sistare |
Subject: |
[PATCH V2 02/22] qemu_ram_volatile |
Date: |
Tue, 5 Jan 2021 07:41:50 -0800 |
Add a function that returns true if any ram_list block represents
volatile memory.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
exec.c | 30 ++++++++++++++++++++++++++++++
include/exec/memory.h | 8 ++++++++
slirp | 2 +-
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/exec.c b/exec.c
index 6f381f9..d1f31b4 100644
--- a/exec.c
+++ b/exec.c
@@ -2726,6 +2726,36 @@ ram_addr_t qemu_ram_addr_from_host(void *ptr)
return block->offset + offset;
}
+/*
+ * 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;
+}
+
/* Generate a debug exception if a watchpoint has been hit. */
void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len,
MemTxAttrs attrs, int flags, uintptr_t ra)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 8dba065..6115a01 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -2522,6 +2522,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/slirp b/slirp
index ce94eba..a62d367 160000
--- a/slirp
+++ b/slirp
@@ -1 +1 @@
-Subproject commit ce94eba2042d52a0ba3d9e252ebce86715e94275
+Subproject commit a62d36734ffe9828d0f70df1b3898a3b4fbda755
--
1.8.3.1
- [PATCH V2 16/22] chardev: cpr for pty, (continued)
- [PATCH V2 16/22] chardev: cpr for pty, Steve Sistare, 2021/01/05
- [PATCH V2 18/22] chardev: cpr for sockets, Steve Sistare, 2021/01/05
- [PATCH V2 19/22] monitor: cpr support, Steve Sistare, 2021/01/05
- [PATCH V2 17/22] chardev: socket accept subroutine, Steve Sistare, 2021/01/05
- [PATCH V2 20/22] cpr: only-cpr-capable option, Steve Sistare, 2021/01/05
- [PATCH V2 22/22] simplify savevm, Steve Sistare, 2021/01/05
- [PATCH V2 14/22] chardev: cpr framework, Steve Sistare, 2021/01/05
- [PATCH V2 21/22] cpr: maintainers, Steve Sistare, 2021/01/05
- [PATCH V2 02/22] qemu_ram_volatile,
Steve Sistare <=
- [PATCH V2 13/22] vhost: reset vhost devices upon cprsave, Steve Sistare, 2021/01/05
- [PATCH V2 01/22] as_flat_walk, Steve Sistare, 2021/01/05
- [PATCH V2 11/22] vfio-pci: refactor for cpr, Steve Sistare, 2021/01/05
- [PATCH V2 15/22] chardev: cpr for simple devices, Steve Sistare, 2021/01/05