qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>, Cleber Rosa <crosa@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] dump-guest-memory.py: fix python 2 support
Date: Wed, 17 Jan 2018 15:18:30 +0100	[thread overview]
Message-ID: <a9bc4b35-23b3-515f-9ba1-71f41a95b9e7@redhat.com> (raw)
In-Reply-To: <20180117114430.19110-1-marcandre.lureau@redhat.com>

On 01/17/18 12:44, Marc-André Lureau wrote:
> 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)

OOP is awesome.

> 
> Fixes a regression introduced with commit
> d23bfa91b7789534d16ede6cb7d925bfac3f3c4c ("add vmcoreinfo").

Do you want to CC stable? Commit d23bfa91b778 is part of v2.11.0.

> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@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."""
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Laszlo

  reply	other threads:[~2018-01-17 14:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 11:44 [Qemu-devel] [PATCH] dump-guest-memory.py: fix python 2 support Marc-André Lureau
2018-01-17 14:18 ` Laszlo Ersek [this message]
2018-01-17 14:59   ` Eric Blake
2018-01-17 15:36     ` Marc-André Lureau
2018-01-17 14:46 ` Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9bc4b35-23b3-515f-9ba1-71f41a95b9e7@redhat.com \
    --to=lersek@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).