Split out dump-guest-memory memory mapping code
PATCH v2 1/1 Split out dump-guest-memory memory mapping code
From: Ekaterina Tumanova <[email protected]>
Split out dump-guest-memory memory mapping code to allow dumping without memory mapping
The qemu dump.c code currently requires CONFIG_HAVE_CORE_DUMP as well as CONFIG_HAVE_GET_MEMORY_MAPPING. This allows for dumping with and without paging. Some architectures will provide only the non-paging case. This patch allows an architecture to provide dumping even when CONFIG_HAVE_GET_MEMORY_MAPPING is not available. To do that, we split out the common code and provide stub functions for the non-paging case. If -p is specified on a target that doesn't support it, we will pass an error to the calling code.
---v1->v2:
- use error_setg instead of introducing new QERR constant
---
Makefile.target | 2 +- dump.c | 10 +++- include/sysemu/memory_mapping.h | 10 ++++ memory_mapping-stub.c | 11 +---- memory_mapping.c | 84 +------------------------------- memory_mapping_common.c | 103 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 127 insertions(+), 93 deletions(-) create mode 100644 memory_mapping_common.c
Makefile.target +1 -1
@@ -112,7 +112,7 @@ obj-$(CONFIG_FDT) += device_tree.o obj-$(CONFIG_KVM) += kvm-all.o obj-y += memory.o savevm.o cputlb.o obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += memory_mapping.o -obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o +obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o memory_mapping_common.o obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o obj-$(CONFIG_NO_CORE_DUMP) += dump-stub.o LIBS+=$(libs_softmmu)
dump.c +9 -1
@@ -756,7 +756,10 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter,/* get memory mapping */ memory_mapping_list_init (&s->list);if (paging) { -qemu_get_guest_memory_mapping (&s->list); + ret =qemu_get_guest_memory_mapping (&s->list); +if (ret <0 ) { + goto cleanup; + } }else {qemu_get_guest_simple_memory_mapping (&s->list); }
@@ -826,6 +829,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,DumpState *s;int ret; +if (paging && !memory_mapping_allowed ()) { +error_setg (errp,"Option paging is not supported for current architecture" ); +return ; + } +if (has_begin && !has_length) {error_set (errp,QERR_MISSING_PARAMETER ,"length" );return ;
include/sysemu/memory_mapping.h +10 -0
@@ -38,6 +38,15 @@ bool cpu_paging_enabled(CPUArchState *env);* memory mapping's list. The region's virtual address starts with virt_addr, * and is contiguous. The list is sorted by phys_addr. */ + +void memory_mapping_list_add_mapping_sorted (MemoryMappingList *list, +MemoryMapping *mapping); + +void create_new_memory_mapping (MemoryMappingList *list, +hwaddr phys_addr, +hwaddr virt_addr, +ram_addr_t length); + void memory_mapping_list_add_merge_sorted(MemoryMappingList *list, hwaddr phys_addr, hwaddr virt_addr,
@@ -60,5 +69,6 @@ void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list);void memory_mapping_filter (MemoryMappingList *list,int64_t begin,int64_t length); +bool memory_mapping_allowed (void );#endif
memory_mapping-stub.c +2 -9
@@ -20,14 +20,7 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list)return -2 ; } -int cpu_get_memory_mapping (MemoryMappingList *list, -CPUArchState *env) +bool memory_mapping_allowed (void ) { -return -1 ; +return false; } - -bool cpu_paging_enabled (CPUArchState *env) -{ -return true; -} -
memory_mapping.c +2 -82
102 lines not on this page · raw message
memory_mapping_common.c new file +103 -0
103 lines not on this page · raw message
Signature · 1 line
1.8.1.6
Andreas Färber
AppliedAm 17.05.2013 22:11, schrieb Jens Freimann:
Quoted 13 lines
From: Ekaterina Tumanova <[email protected]>
Split out dump-guest-memory memory mapping code to allow dumping without memory mapping
The qemu
dump.ccode currently requiresCONFIG_HAVE_CORE_DUMPas well asCONFIG_HAVE_GET_MEMORY_MAPPING. This allows for dumping with and without paging. Some architectures will provide only the non-paging case. This patch allows an architecture to provide dumping even whenCONFIG_HAVE_GET_MEMORY_MAPPINGis not available. To do that, we split out the common code and provide stub functions for the non-paging case. If -p is specified on a target that doesn't support it, we will pass an error to the calling code.
Quoted 6 lines
Signed-off-by Ekaterina Tumanova <[email protected]>Signed-off-by Jens Freimann <[email protected]>---
v1->v2:
- useerror_setginstead of introducing new QERR constant
Thanks, applied to qom-cpu (with commit message redundancy reduced and one change below):
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
Quoted 10 lines
---
Makefile.target | 2 +- dump.c | 10 +++- include/sysemu/memory_mapping.h | 10 ++++ memory_mapping-stub.c | 11 +---- memory_mapping.c | 84 +------------------------------- memory_mapping_common.c | 103 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 127 insertions(+), 93 deletions(-) create mode 100644 memory_mapping_common.c
[...]
Quoted 4 lines
dump.c +0
-0
[...]
dump.c void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, · line 834
Quoted 7 lines
dump.c +3
-0@@ -826,6 +829,11 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,DumpState *s;int ret; +if (paging && !memory_mapping_allowed ()) { +error_setg (errp,"Option paging is not supported for current architecture" ); +return ;
Fixed the indentation and broke the line to stay within 80 chars.
dump.c void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, · line 839
Quoted 5 lines
dump.c +2
-0+ } +if (has_begin && !has_length) {error_set (errp,QERR_MISSING_PARAMETER ,"length" );return ;
[snip]
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg