* [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support
2018-01-17 14:47 Marc-André Lureau
@ 2018-01-17 14:47 ` Marc-André Lureau
0 siblings, 0 replies; 4+ messages in thread
From: Marc-André Lureau @ 2018-01-17 14:47 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Marc-André Lureau, Eduardo Habkost,
Cleber Rosa
Python GDB support may use Python 2 or 3.
Inferior.read_memory() may return a buffer with Python 2 or a
memoryview with Python 3 (see also
https://sourceware.org/gdb/onlinedocs/gdb/Inferiors-In-Python.html)
The elf.add_vmcoreinfo_note() method expect a byte string, but Python 2
buffer doesn't provide the tobyes() method. Wrap the read_memory()
result to a memoryview, available in Python 2.7. (if the return object
is already a memoryview, this adds a useless identity view on top)
Fixes a regression introduced with commit
d23bfa91b7789534d16ede6cb7d925bfac3f3c4c ("add vmcoreinfo").
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
scripts/dump-guest-memory.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
index 09bec92b50..6f7e1a83b3 100644
--- a/scripts/dump-guest-memory.py
+++ b/scripts/dump-guest-memory.py
@@ -564,7 +564,9 @@ shape and this command should mostly work."""
vmcoreinfo = self.phys_memory_read(addr, size)
if vmcoreinfo:
- self.elf.add_vmcoreinfo_note(vmcoreinfo.tobytes())
+ # Python 2.7 returns a buffer
+ vmciview = memoryview(vmcoreinfo)
+ self.elf.add_vmcoreinfo_note(vmciview.tobytes())
def invoke(self, args, from_tty):
"""Handles command invocation from gdb."""
--
2.16.0.rc1.1.gef27df75a1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL 0/1] Dump patches
@ 2018-01-20 20:03 Marc-André Lureau
2018-01-20 20:03 ` [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support Marc-André Lureau
2018-01-22 12:22 ` [Qemu-devel] [PULL 0/1] Dump patches Peter Maydell
0 siblings, 2 replies; 4+ messages in thread
From: Marc-André Lureau @ 2018-01-20 20:03 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Marc-André Lureau
The following changes since commit b384cd95eb9c6f73ad84ed1bb0717a26e29cc78f:
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging (2018-01-19 16:35:25 +0000)
are available in the Git repository at:
https://github.com/elmarco/qemu.git tags/dump-pull-request
for you to fetch changes up to 6f49ec4034e55dfb675a56a62c9579384f7fb8cc:
dump-guest-memory.py: fix python 2 support (2018-01-20 20:59:00 +0100)
----------------------------------------------------------------
----------------------------------------------------------------
Marc-André Lureau (1):
dump-guest-memory.py: fix python 2 support
scripts/dump-guest-memory.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
2.16.0.rc1.1.gef27df75a1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support
2018-01-20 20:03 [Qemu-devel] [PULL 0/1] Dump patches Marc-André Lureau
@ 2018-01-20 20:03 ` Marc-André Lureau
2018-01-22 12:22 ` [Qemu-devel] [PULL 0/1] Dump patches Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Marc-André Lureau @ 2018-01-20 20:03 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, Marc-André Lureau, Eduardo Habkost,
Cleber Rosa
Python GDB support may use Python 2 or 3.
Inferior.read_memory() may return a 'buffer' with Python 2 or a
'memoryview' with Python 3 (see also
https://sourceware.org/gdb/onlinedocs/gdb/Inferiors-In-Python.html)
The elf.add_vmcoreinfo_note() method expects a "bytes" object. Wrap
the returned memory with bytes(), which works with both 'memoryview'
and 'buffer'.
Fixes a regression introduced with commit
d23bfa91b7789534d16ede6cb7d925bfac3f3c4c ("add vmcoreinfo").
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
scripts/dump-guest-memory.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
index 09bec92b50..03fbf69f8a 100644
--- a/scripts/dump-guest-memory.py
+++ b/scripts/dump-guest-memory.py
@@ -564,7 +564,7 @@ shape and this command should mostly work."""
vmcoreinfo = self.phys_memory_read(addr, size)
if vmcoreinfo:
- self.elf.add_vmcoreinfo_note(vmcoreinfo.tobytes())
+ self.elf.add_vmcoreinfo_note(bytes(vmcoreinfo))
def invoke(self, args, from_tty):
"""Handles command invocation from gdb."""
--
2.16.0.rc1.1.gef27df75a1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PULL 0/1] Dump patches
2018-01-20 20:03 [Qemu-devel] [PULL 0/1] Dump patches Marc-André Lureau
2018-01-20 20:03 ` [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support Marc-André Lureau
@ 2018-01-22 12:22 ` Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-01-22 12:22 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: QEMU Developers
On 20 January 2018 at 20:03, Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
> The following changes since commit b384cd95eb9c6f73ad84ed1bb0717a26e29cc78f:
>
> Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging (2018-01-19 16:35:25 +0000)
>
> are available in the Git repository at:
>
> https://github.com/elmarco/qemu.git tags/dump-pull-request
>
> for you to fetch changes up to 6f49ec4034e55dfb675a56a62c9579384f7fb8cc:
>
> dump-guest-memory.py: fix python 2 support (2018-01-20 20:59:00 +0100)
>
> ----------------------------------------------------------------
>
> ----------------------------------------------------------------
>
> Marc-André Lureau (1):
> dump-guest-memory.py: fix python 2 support
>
> scripts/dump-guest-memory.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-22 12:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-20 20:03 [Qemu-devel] [PULL 0/1] Dump patches Marc-André Lureau
2018-01-20 20:03 ` [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support Marc-André Lureau
2018-01-22 12:22 ` [Qemu-devel] [PULL 0/1] Dump patches Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2018-01-17 14:47 Marc-André Lureau
2018-01-17 14:47 ` [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support Marc-André Lureau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).