QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] Handle gdb.MemoryError exception in dump-guest-memory.py
@ 2020-02-14 23:26 Kevin Buettner
  2020-02-14 23:34 ` no-reply
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Buettner @ 2020-02-14 23:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Buettner

I recently investigated a bug in which the dump-guest-memory.py script
sees a gdb.MemoryError exception while attempting to dump memory
obtained from a QEMU core dump.  (And, yes, dump-guest-core=on was
specified in the -machine option of the QEMU invocation.)

It turns out that memory region in question is not being placed in the
core dump and, after stepping through the kernel core dumping code
responsible for making this decision, it looks reasonable to me to not
include that region in the core dump.  The region in question consists
of all zeros and, according to the kernel's logic, has never been
written to.

This commit makes a small change to the dump-guest-memory script to
cause inaccessible memory to be dumped as zeroes.  This avoids the
exception and places the correct values in the guest memory dump.
---
 scripts/dump-guest-memory.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
index 4177261d33..fbdfba458b 100644
--- a/scripts/dump-guest-memory.py
+++ b/scripts/dump-guest-memory.py
@@ -539,7 +539,12 @@ shape and this command should mostly work."""
 
             while left > 0:
                 chunk_size = min(TARGET_PAGE_SIZE, left)
-                chunk = qemu_core.read_memory(cur, chunk_size)
+                try:
+                    chunk = qemu_core.read_memory(cur, chunk_size)
+                except gdb.MemoryError:
+                    # Consider blocks of memory absent from a core file
+                    # as being zeroed.
+                    chunk = bytes(chunk_size)
                 vmcore.write(chunk)
                 cur += chunk_size
                 left -= chunk_size
-- 
2.24.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Handle gdb.MemoryError exception in dump-guest-memory.py
  2020-02-14 23:26 [PATCH] Handle gdb.MemoryError exception in dump-guest-memory.py Kevin Buettner
@ 2020-02-14 23:34 ` no-reply
  0 siblings, 0 replies; 2+ messages in thread
From: no-reply @ 2020-02-14 23:34 UTC (permalink / raw)
  To: kevinb; +Cc: qemu-devel, kevinb

Patchew URL: https://patchew.org/QEMU/20200214232650.35381-1-kevinb@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH] Handle gdb.MemoryError exception in dump-guest-memory.py
Message-id: 20200214232650.35381-1-kevinb@redhat.com
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
 * [new tag]         patchew/20200214232650.35381-1-kevinb@redhat.com -> patchew/20200214232650.35381-1-kevinb@redhat.com
Switched to a new branch 'test'
b41300a Handle gdb.MemoryError exception in dump-guest-memory.py

=== OUTPUT BEGIN ===
ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 0 warnings, 13 lines checked

Commit b41300af0818 (Handle gdb.MemoryError exception in dump-guest-memory.py) has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20200214232650.35381-1-kevinb@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 23:26 [PATCH] Handle gdb.MemoryError exception in dump-guest-memory.py Kevin Buettner
2020-02-14 23:34 ` no-reply

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org
	public-inbox-index qemu-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git