9ae3a8
From 8bd9fce5250f9abcca1e80afb5425bcf6e867b28 Mon Sep 17 00:00:00 2001
9ae3a8
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
9ae3a8
Date: Mon, 22 Jan 2018 14:04:40 +0100
9ae3a8
Subject: [PATCH 2/3] dump-guest-memory.py: fix python 2 support
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
9ae3a8
Message-id: <20180122140440.24988-1-marcandre.lureau@redhat.com>
9ae3a8
Patchwork-id: 78692
9ae3a8
O-Subject: [RHEL-7.5 qemu-kvm PATCH v2] dump-guest-memory.py: fix python 2 support
9ae3a8
Bugzilla: 1411490
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
Python GDB support may use Python 2 or 3.
9ae3a8
9ae3a8
Inferior.read_memory() may return a 'buffer' with Python 2 or a
9ae3a8
'memoryview' with Python 3 (see also
9ae3a8
https://sourceware.org/gdb/onlinedocs/gdb/Inferiors-In-Python.html)
9ae3a8
9ae3a8
The elf.add_vmcoreinfo_note() method expects a "bytes" object. Wrap
9ae3a8
the returned memory with bytes(), which works with both 'memoryview'
9ae3a8
and 'buffer'.
9ae3a8
9ae3a8
Fixes a regression introduced with commit
9ae3a8
d23bfa91b7789534d16ede6cb7d925bfac3f3c4c ("add vmcoreinfo").
9ae3a8
9ae3a8
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
9ae3a8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9ae3a8
Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
9ae3a8
(cherry picked from commit 6f49ec4034e55dfb675a56a62c9579384f7fb8cc)
9ae3a8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 scripts/dump-guest-memory.py | 2 +-
9ae3a8
 1 file changed, 1 insertion(+), 1 deletion(-)
9ae3a8
9ae3a8
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
9ae3a8
index 8a13db0..adb942e 100644
9ae3a8
--- a/scripts/dump-guest-memory.py
9ae3a8
+++ b/scripts/dump-guest-memory.py
9ae3a8
@@ -564,7 +564,7 @@ shape and this command should mostly work."""
9ae3a8
 
9ae3a8
         vmcoreinfo = self.phys_memory_read(addr, size)
9ae3a8
         if vmcoreinfo:
9ae3a8
-            self.elf.add_vmcoreinfo_note(vmcoreinfo.tobytes())
9ae3a8
+            self.elf.add_vmcoreinfo_note(bytes(vmcoreinfo))
9ae3a8
 
9ae3a8
     def invoke(self, args, from_tty):
9ae3a8
         """Handles command invocation from gdb."""
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8