All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/1] Dump patches
@ 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
  2018-01-17 15:02 ` [Qemu-devel] [PULL 0/1] Dump patches Eric Blake
  0 siblings, 2 replies; 12+ messages in thread
From: Marc-André Lureau @ 2018-01-17 14:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, Marc-André Lureau

The following changes since commit 8e5dc9ba49743b46d955ec7dacb04e42ae7ada7c:

  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180116' into staging (2018-01-16 17:36:39 +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 48fb74965a8d8f2916da30d9c5b9945df25142af:

  dump-guest-memory.py: fix python 2 support (2018-01-17 15:47:14 +0100)

----------------------------------------------------------------

----------------------------------------------------------------

Marc-André Lureau (1):
  dump-guest-memory.py: fix python 2 support

 scripts/dump-guest-memory.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.16.0.rc1.1.gef27df75a1

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

* [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support
  2018-01-17 14:47 [Qemu-devel] [PULL 0/1] Dump patches Marc-André Lureau
@ 2018-01-17 14:47 ` Marc-André Lureau
  2018-01-17 15:02 ` [Qemu-devel] [PULL 0/1] Dump patches Eric Blake
  1 sibling, 0 replies; 12+ 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] 12+ messages in thread

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-17 14:47 [Qemu-devel] [PULL 0/1] Dump patches Marc-André Lureau
  2018-01-17 14:47 ` [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support Marc-André Lureau
@ 2018-01-17 15:02 ` Eric Blake
  2018-01-19 14:29   ` Peter Maydell
  1 sibling, 1 reply; 12+ messages in thread
From: Eric Blake @ 2018-01-17 15:02 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: peter.maydell

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

On 01/17/2018 08:47 AM, Marc-André Lureau wrote:
> The following changes since commit 8e5dc9ba49743b46d955ec7dacb04e42ae7ada7c:
> 
>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180116' into staging (2018-01-16 17:36:39 +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 48fb74965a8d8f2916da30d9c5b9945df25142af:
> 
>   dump-guest-memory.py: fix python 2 support (2018-01-17 15:47:14 +0100)
> 

The commit says it works with python 2.7, but we still require support
for python 2.6.  Is this pull request premature?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

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

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-17 15:02 ` [Qemu-devel] [PULL 0/1] Dump patches Eric Blake
@ 2018-01-19 14:29   ` Peter Maydell
  2018-01-19 14:35     ` Marc-Andre Lureau
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2018-01-19 14:29 UTC (permalink / raw)
  To: Eric Blake; +Cc: Marc-André Lureau, QEMU Developers

On 17 January 2018 at 15:02, Eric Blake <eblake@redhat.com> wrote:
> On 01/17/2018 08:47 AM, Marc-André Lureau wrote:
>> The following changes since commit 8e5dc9ba49743b46d955ec7dacb04e42ae7ada7c:
>>
>>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180116' into staging (2018-01-16 17:36:39 +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 48fb74965a8d8f2916da30d9c5b9945df25142af:
>>
>>   dump-guest-memory.py: fix python 2 support (2018-01-17 15:47:14 +0100)
>>
>
> The commit says it works with python 2.7, but we still require support
> for python 2.6.  Is this pull request premature?

So should I apply this, or not?

thanks
-- PMM

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

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-19 14:29   ` Peter Maydell
@ 2018-01-19 14:35     ` Marc-Andre Lureau
  2018-01-19 14:56       ` Eric Blake
  2018-01-19 15:24       ` Peter Maydell
  0 siblings, 2 replies; 12+ messages in thread
From: Marc-Andre Lureau @ 2018-01-19 14:35 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Eric Blake, Marc-André Lureau, QEMU Developers

Hi

On Fri, Jan 19, 2018 at 3:29 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 17 January 2018 at 15:02, Eric Blake <eblake@redhat.com> wrote:
>> On 01/17/2018 08:47 AM, Marc-André Lureau wrote:
>>> The following changes since commit 8e5dc9ba49743b46d955ec7dacb04e42ae7ada7c:
>>>
>>>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180116' into staging (2018-01-16 17:36:39 +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 48fb74965a8d8f2916da30d9c5b9945df25142af:
>>>
>>>   dump-guest-memory.py: fix python 2 support (2018-01-17 15:47:14 +0100)
>>>
>>
>> The commit says it works with python 2.7, but we still require support
>> for python 2.6.  Is this pull request premature?
>
> So should I apply this, or not?

I have not found how to translate a python 'buffer' to a bytes string
in 2.6. For now, I think we should go with this patch, it's already an
improvement..

Thanks

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

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-19 14:35     ` Marc-Andre Lureau
@ 2018-01-19 14:56       ` Eric Blake
  2018-01-19 15:24       ` Peter Maydell
  1 sibling, 0 replies; 12+ messages in thread
From: Eric Blake @ 2018-01-19 14:56 UTC (permalink / raw)
  To: Marc-Andre Lureau, Peter Maydell; +Cc: Marc-André Lureau, QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 1312 bytes --]

On 01/19/2018 08:35 AM, Marc-Andre Lureau wrote:

>>>>   dump-guest-memory.py: fix python 2 support (2018-01-17 15:47:14 +0100)
>>>>
>>>
>>> The commit says it works with python 2.7, but we still require support
>>> for python 2.6.  Is this pull request premature?
>>
>> So should I apply this, or not?
> 
> I have not found how to translate a python 'buffer' to a bytes string
> in 2.6. For now, I think we should go with this patch, it's already an
> improvement..

Argument in favor of applying: dump-guest-memory.py is not run as part
of the build process, nor during 'make check'; rather, it is an add-on
script for developer convenience after installation.  If we apply the
patch, we break developers on machines using python 2.6, but fix things
for developers on machines with python 3 - and as time (and Fedora
rawhide) march on, the balance swings in favor of the latter.

I personally am not enough of a python expert to propose a fix that
works across all versions supported by configure, but it was Marc-Andre
reminding me on IRC that this is not a build script, so it can have
different standards than our build when it comes to portability.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

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

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-19 14:35     ` Marc-Andre Lureau
  2018-01-19 14:56       ` Eric Blake
@ 2018-01-19 15:24       ` Peter Maydell
  2018-01-19 15:29         ` Peter Maydell
  1 sibling, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2018-01-19 15:24 UTC (permalink / raw)
  To: Marc-Andre Lureau; +Cc: Eric Blake, Marc-André Lureau, QEMU Developers

On 19 January 2018 at 14:35, Marc-Andre Lureau <mlureau@redhat.com> wrote:
> I have not found how to translate a python 'buffer' to a bytes string
> in 2.6.

A local python expert suggests that "bytes(buffer)" should work.

thanks
-- PMM

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

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-19 15:24       ` Peter Maydell
@ 2018-01-19 15:29         ` Peter Maydell
  2018-01-19 16:08           ` Marc-Andre Lureau
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2018-01-19 15:29 UTC (permalink / raw)
  To: Marc-Andre Lureau; +Cc: Eric Blake, Marc-André Lureau, QEMU Developers

On 19 January 2018 at 15:24, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 19 January 2018 at 14:35, Marc-Andre Lureau <mlureau@redhat.com> wrote:
>> I have not found how to translate a python 'buffer' to a bytes string
>> in 2.6.
>
> A local python expert suggests that "bytes(buffer)" should work.

...and that it ought to work if handed a memoryview too, so do we
just want

   self.elf.add_vmcoreinfo_note(bytes(vmcoreinfo))

?

thanks
-- PMM

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

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-19 15:29         ` Peter Maydell
@ 2018-01-19 16:08           ` Marc-Andre Lureau
  2018-01-19 16:21             ` Peter Maydell
  0 siblings, 1 reply; 12+ messages in thread
From: Marc-Andre Lureau @ 2018-01-19 16:08 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Eric Blake, Marc-André Lureau, QEMU Developers

Hi

On Fri, Jan 19, 2018 at 4:29 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 19 January 2018 at 15:24, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 19 January 2018 at 14:35, Marc-Andre Lureau <mlureau@redhat.com> wrote:
>>> I have not found how to translate a python 'buffer' to a bytes string
>>> in 2.6.
>>
>> A local python expert suggests that "bytes(buffer)" should work.
>
> ...and that it ought to work if handed a memoryview too, so do we
> just want
>
>    self.elf.add_vmcoreinfo_note(bytes(vmcoreinfo))
>

Yes, I tested on 2.6 and 3.6, it works. I'll send a new patch.

Thanks!

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

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-19 16:08           ` Marc-Andre Lureau
@ 2018-01-19 16:21             ` Peter Maydell
  2018-01-19 16:27               ` Marc-Andre Lureau
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Maydell @ 2018-01-19 16:21 UTC (permalink / raw)
  To: Marc-Andre Lureau; +Cc: Eric Blake, Marc-André Lureau, QEMU Developers

On 19 January 2018 at 16:08, Marc-Andre Lureau <mlureau@redhat.com> wrote:
> Hi
>
> On Fri, Jan 19, 2018 at 4:29 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 19 January 2018 at 15:24, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> On 19 January 2018 at 14:35, Marc-Andre Lureau <mlureau@redhat.com> wrote:
>>>> I have not found how to translate a python 'buffer' to a bytes string
>>>> in 2.6.
>>>
>>> A local python expert suggests that "bytes(buffer)" should work.
>>
>> ...and that it ought to work if handed a memoryview too, so do we
>> just want
>>
>>    self.elf.add_vmcoreinfo_note(bytes(vmcoreinfo))
>>
>
> Yes, I tested on 2.6 and 3.6, it works. I'll send a new patch.

Testing 2.7 as well would probably not be a bad plan. Apparently
this works because:
 * on python 3, bytes(memoryview) and memoryview.to_bytes() are the same
 * gdb gives us a memoryview only if python 3
 * so we don't have to handle the case of getting a memoryview and
   being python 2 (in which case we would need to use memoryview.to_bytes()
   as bytes() would do the wrong thing)

thanks
-- PMM

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

* Re: [Qemu-devel] [PULL 0/1] Dump patches
  2018-01-19 16:21             ` Peter Maydell
@ 2018-01-19 16:27               ` Marc-Andre Lureau
  0 siblings, 0 replies; 12+ messages in thread
From: Marc-Andre Lureau @ 2018-01-19 16:27 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Eric Blake, Marc-André Lureau, QEMU Developers

On Fri, Jan 19, 2018 at 5:21 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 19 January 2018 at 16:08, Marc-Andre Lureau <mlureau@redhat.com> wrote:
>> Hi
>>
>> On Fri, Jan 19, 2018 at 4:29 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> On 19 January 2018 at 15:24, Peter Maydell <peter.maydell@linaro.org> wrote:
>>>> On 19 January 2018 at 14:35, Marc-Andre Lureau <mlureau@redhat.com> wrote:
>>>>> I have not found how to translate a python 'buffer' to a bytes string
>>>>> in 2.6.
>>>>
>>>> A local python expert suggests that "bytes(buffer)" should work.
>>>
>>> ...and that it ought to work if handed a memoryview too, so do we
>>> just want
>>>
>>>    self.elf.add_vmcoreinfo_note(bytes(vmcoreinfo))
>>>
>>
>> Yes, I tested on 2.6 and 3.6, it works. I'll send a new patch.
>
> Testing 2.7 as well would probably not be a bad plan. Apparently
> this works because:
>  * on python 3, bytes(memoryview) and memoryview.to_bytes() are the same
>  * gdb gives us a memoryview only if python 3
>  * so we don't have to handle the case of getting a memoryview and
>    being python 2 (in which case we would need to use memoryview.to_bytes()
>    as bytes() would do the wrong thing)

I just tested with 2.7 as well, works fine too.

Updated patch sent.

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

* [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support
  2018-01-20 20:03 Marc-André Lureau
@ 2018-01-20 20:03 ` Marc-André Lureau
  0 siblings, 0 replies; 12+ 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] 12+ messages in thread

end of thread, other threads:[~2018-01-20 20:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17 14:47 [Qemu-devel] [PULL 0/1] Dump patches Marc-André Lureau
2018-01-17 14:47 ` [Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support Marc-André Lureau
2018-01-17 15:02 ` [Qemu-devel] [PULL 0/1] Dump patches Eric Blake
2018-01-19 14:29   ` Peter Maydell
2018-01-19 14:35     ` Marc-Andre Lureau
2018-01-19 14:56       ` Eric Blake
2018-01-19 15:24       ` Peter Maydell
2018-01-19 15:29         ` Peter Maydell
2018-01-19 16:08           ` Marc-Andre Lureau
2018-01-19 16:21             ` Peter Maydell
2018-01-19 16:27               ` Marc-Andre Lureau
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.