diff options
author | Wen Congyang <wency@cn.fujitsu.com> | 2012-05-07 12:10:47 +0800 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2012-06-04 13:49:34 -0300 |
commit | 783e9b4826b95e53e33c42db6b4bd7d89bdff147 (patch) | |
tree | cf82afb895f2289e30b926b3801e925cb90cd32b /memory_mapping.c | |
parent | 68f4730c714b7c30ca912d7c03e199f181739da0 (diff) | |
download | qemu-783e9b4826b95e53e33c42db6b4bd7d89bdff147.zip qemu-783e9b4826b95e53e33c42db6b4bd7d89bdff147.tar.gz qemu-783e9b4826b95e53e33c42db6b4bd7d89bdff147.tar.bz2 |
introduce a new monitor command 'dump-guest-memory' to dump guest's memory
The command's usage:
dump-guest-memory [-p] protocol [begin] [length]
The supported protocol can be file or fd:
1. file: the protocol starts with "file:", and the following string is
the file's path.
2. fd: the protocol starts with "fd:", and the following string is the
fd's name.
Note:
1. If you want to use gdb to process the core, please specify -p option.
The reason why the -p option is not default is:
a. guest machine in a catastrophic state can have corrupted memory,
which we cannot trust.
b. The guest machine can be in read-mode even if paging is enabled.
For example: the guest machine uses ACPI to sleep, and ACPI sleep
state goes in real-mode.
2. If you don't want to dump all guest's memory, please specify the start
physical address and the length.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'memory_mapping.c')
-rw-r--r-- | memory_mapping.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/memory_mapping.c b/memory_mapping.c index adb1595..8810bb0 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -220,3 +220,30 @@ void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list) create_new_memory_mapping(list, block->offset, 0, block->length); } } + +void memory_mapping_filter(MemoryMappingList *list, int64_t begin, + int64_t length) +{ + MemoryMapping *cur, *next; + + QTAILQ_FOREACH_SAFE(cur, &list->head, next, next) { + if (cur->phys_addr >= begin + length || + cur->phys_addr + cur->length <= begin) { + QTAILQ_REMOVE(&list->head, cur, next); + list->num--; + continue; + } + + if (cur->phys_addr < begin) { + cur->length -= begin - cur->phys_addr; + if (cur->virt_addr) { + cur->virt_addr += begin - cur->phys_addr; + } + cur->phys_addr = begin; + } + + if (cur->phys_addr + cur->length > begin + length) { + cur->length -= cur->phys_addr + cur->length - begin - length; + } + } +} |