Skip to contentSkip to conversation

Dump patches

GIT PULL Marc-André Lureau 4 participants 11 messages Jan 17, 2018 – Jan 19, 2018

lore
Share & tools
lore
#0 lore raw

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(-)
Signature · 1 line
2.16.0.rc1.1.gef27df75a1
#1 lore raw

[Qemu-devel] [PULL 1/1] dump-guest-memory.py: fix python 2 support

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").

---
 scripts/dump-guest-memory.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/dump-guest-memory.py +3 -1
index 09bec92b50..6f7e1a83b3 100644
@@ -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."""
Signature · 1 line
2.16.0.rc1.1.gef27df75a1
#2 lore raw
In reply to Marc-André Lureau
Quoted 4 lines · 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)

Quoted 8 lines

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?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#3 lore raw
Quoted 9 lines · Eric Blake
Quoted 8 lines · 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

Quoted 7 lines
Quoted 4 lines

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

#4 lore raw

Hi

Quoted 12 lines · Peter Maydell
Quoted 11 lines · Eric Blake
Quoted 10 lines · 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:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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

#5 lore raw
Quoted 11 lines · Marc-Andre Lureau
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

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.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#6 lore raw
In reply to Marc-Andre Lureau
Quoted 2 lines · Marc-Andre Lureau

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

#7 lore raw
Quoted 5 lines · Peter Maydell
Quoted 2 lines · Marc-Andre Lureau

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

#8 lore raw

Hi

Quoted 5 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Quoted 2 lines · Marc-Andre Lureau

I have not found how to translate a python 'buffer' to a bytes string in 2.6.

Quoted 7 lines
Quoted 1 line

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!

#9 lore raw
Quoted 10 lines · Marc-Andre Lureau

Hi

Quoted 7 lines · Peter Maydell
Quoted 5 lines · Peter Maydell
Quoted 2 lines · Marc-Andre Lureau

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.

Quoted 7 lines
Quoted 5 lines

...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

#10 lore raw
Quoted 19 lines · Peter Maydell
Quoted 10 lines · Marc-Andre Lureau

Hi

Quoted 7 lines · Peter Maydell
Quoted 5 lines · Peter Maydell
Quoted 2 lines · Marc-Andre Lureau

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.

Quoted 7 lines
Quoted 5 lines

...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.

Quoted 7 lines

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.