Dump patches
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
[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
@@ -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
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
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
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
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
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
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
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!
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
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) andmemoryview.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 usememoryview.to_bytes()asbytes()would do the wrong thing)
I just tested with 2.7 as well, works fine too.
Updated patch sent.