[Libguestfs] [libnbd PATCH] python: Correctly use PyGILState

2022-06-09 Thread Eric Blake
The python docs are clear that in a multi-threaded app, we CANNOT call any python functions from C code (other than a short-list of exceptions) without first owning the GIL in the calling thread. Although many users of nbdsh are single-threaded (where the GIL does not matter), it is indeed possible

Re: [Libguestfs] [libnbd PATCH v3 1/5] python: Simplify passing of mutable *error to callbacks

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 03:58:45PM -0500, Eric Blake wrote: > On Thu, Jun 09, 2022 at 11:03:02AM -0500, Eric Blake wrote: > > On Thu, Jun 09, 2022 at 03:22:42PM +0100, Richard W.M. Jones wrote: > > > On Thu, Jun 09, 2022 at 08:34:43AM -0500, Eric Blake wrote: > > > > Instead of open-coding our code

Re: [Libguestfs] [libnbd PATCH v3 1/5] python: Simplify passing of mutable *error to callbacks

2022-06-09 Thread Eric Blake
On Thu, Jun 09, 2022 at 11:03:02AM -0500, Eric Blake wrote: > On Thu, Jun 09, 2022 at 03:22:42PM +0100, Richard W.M. Jones wrote: > > On Thu, Jun 09, 2022 at 08:34:43AM -0500, Eric Blake wrote: > > > Instead of open-coding our code to create a PyObject wrapper of the > > > mutable *error to be pass

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 09:23:50PM +0300, Nir Soffer wrote: > On Thu, Jun 9, 2022 at 6:24 PM Richard W.M. Jones wrote: > > $ emacs -nw run.in# comment out GODEBUG line ... > > $ make -C golang check > > ... > > PASS: run-tests.sh > > So when skipping libnbd_020_aio_buffer_test.go we don't get

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Daniel P . Berrangé
On Thu, Jun 09, 2022 at 05:33:03PM +0100, Richard W.M. Jones wrote: > On Thu, Jun 09, 2022 at 07:22:45PM +0300, Nir Soffer wrote: > > On Thu, Jun 9, 2022 at 6:48 PM Richard W.M. Jones wrote: > > > NB: this _does not_ address the other problem where GODEBUG=cgocheck=2 > > > complains about "fatal e

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Nir Soffer
On Thu, Jun 9, 2022 at 6:24 PM Richard W.M. Jones wrote: > > On Thu, Jun 09, 2022 at 03:20:02PM +0100, Daniel P. Berrangé wrote: > > > + go test -count=1 -v > > > === RUN Test010Load > > > --- PASS: Test010Load (0.00s) > > > === RUN TestAioBuffer > > > --- PASS: TestAioBuffer (0.00s) > > > ===

Re: [Libguestfs] [PATCH libnbd] golang: aio_buffer.go: Explicit panic() on invalid usage

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 08:10:53PM +0300, Nir Soffer wrote: > Previously we depended on the behavior on common platforms to panic when > trying to use a nil pointer, but Richard reported that it segfault on > RISC-V. Avoid the undocumented assumptions and panic explicitly with a > useful panic mess

[Libguestfs] [PATCH libnbd] golang: aio_buffer.go: Explicit panic() on invalid usage

2022-06-09 Thread Nir Soffer
Previously we depended on the behavior on common platforms to panic when trying to use a nil pointer, but Richard reported that it segfault on RISC-V. Avoid the undocumented assumptions and panic explicitly with a useful panic message. Signed-off-by: Nir Soffer --- golang/aio_buffer.go | 9 +

Re: [Libguestfs] [libnbd PATCH v3 2/5] python: Alter lock for persistent buffer

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 11:24:48AM -0500, Eric Blake wrote: > On Thu, Jun 09, 2022 at 03:27:36PM +0100, Richard W.M. Jones wrote: > > > > Post-patch: > > > nbd> b = nbd.Buffer(10) > > > nbd> c = h.aio_pread(b, 0) > > > nbd> b._o.pop() > > > Traceback (most recent call last): > > > File "/usr/lib

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 07:22:45PM +0300, Nir Soffer wrote: > On Thu, Jun 9, 2022 at 6:48 PM Richard W.M. Jones wrote: > > NB: this _does not_ address the other problem where GODEBUG=cgocheck=2 > > complains about "fatal error: Go pointer stored into non-Go memory". > > Do we keep go pointers in

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 05:00:46PM +0100, Daniel P. Berrangé wrote: > Well it isn't use-after-free, because we've cleared the > pointer we freed. Yes, indeed that's what I meant to say! > > It seems a bit of an odd function however. Wouldn't it be better to > > changes the Bytes function so that

Re: [Libguestfs] [libnbd PATCH v3 3/5] python: Accept all buffer-like objects in aio_p{read, write}

2022-06-09 Thread Eric Blake
On Thu, Jun 09, 2022 at 03:31:02PM +0100, Richard W.M. Jones wrote: > On Thu, Jun 09, 2022 at 08:34:45AM -0500, Eric Blake wrote: > > After the work in the previous patches, it is now a trivial feature > > addition to support any buffer-like object as the argument to > > h.aio_{pread,pwrite}, and m

Re: [Libguestfs] [libnbd PATCH v3 2/5] python: Alter lock for persistent buffer

2022-06-09 Thread Eric Blake
On Thu, Jun 09, 2022 at 03:27:36PM +0100, Richard W.M. Jones wrote: > > Post-patch: > > nbd> b = nbd.Buffer(10) > > nbd> c = h.aio_pread(b, 0) > > nbd> b._o.pop() > > Traceback (most recent call last): > > File "/usr/lib64/python3.10/code.py", line 90, in runcode > > exec(code, self.locals)

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Nir Soffer
On Thu, Jun 9, 2022 at 6:48 PM Richard W.M. Jones wrote: > > On Thu, Jun 09, 2022 at 04:24:12PM +0100, Richard W.M. Jones wrote: > > On Thu, Jun 09, 2022 at 03:20:02PM +0100, Daniel P. Berrangé wrote: > > > > + go test -count=1 -v > > > > === RUN Test010Load > > > > --- PASS: Test010Load (0.00s)

Re: [Libguestfs] [libnbd PATCH v3 1/5] python: Simplify passing of mutable *error to callbacks

2022-06-09 Thread Eric Blake
On Thu, Jun 09, 2022 at 03:22:42PM +0100, Richard W.M. Jones wrote: > On Thu, Jun 09, 2022 at 08:34:43AM -0500, Eric Blake wrote: > > Instead of open-coding our code to create a PyObject wrapper of the > > mutable *error to be passed to each callback, extract this into a > > helper function. We ca

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Daniel P . Berrangé
On Thu, Jun 09, 2022 at 04:48:34PM +0100, Richard W.M. Jones wrote: > On Thu, Jun 09, 2022 at 04:24:12PM +0100, Richard W.M. Jones wrote: > > On Thu, Jun 09, 2022 at 03:20:02PM +0100, Daniel P. Berrangé wrote: > > > > + go test -count=1 -v > > > > === RUN Test010Load > > > > --- PASS: Test010Load

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 04:24:12PM +0100, Richard W.M. Jones wrote: > On Thu, Jun 09, 2022 at 03:20:02PM +0100, Daniel P. Berrangé wrote: > > > + go test -count=1 -v > > > === RUN Test010Load > > > --- PASS: Test010Load (0.00s) > > > === RUN TestAioBuffer > > > --- PASS: TestAioBuffer (0.00s) >

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 03:20:02PM +0100, Daniel P. Berrangé wrote: > > + go test -count=1 -v > > === RUN Test010Load > > --- PASS: Test010Load (0.00s) > > === RUN TestAioBuffer > > --- PASS: TestAioBuffer (0.00s) > > === RUN TestAioBufferFree > > --- PASS: TestAioBufferFree (0.00s) > > === R

Re: [Libguestfs] [libnbd PATCH v3 5/5] python: Slice structured read callback buffer from original

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 08:34:47AM -0500, Eric Blake wrote: > The Py_BuildValue "y#" format copies data; this is because Python > assumes our C memory can go out of scope, while the user's python > callback can stash off whatever bytearray object it got. But this > copying is inefficient. Now tha

Re: [Libguestfs] [libnbd PATCH v3 4/5] python: Support len(nbd.Buffer(n))

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 08:34:46AM -0500, Eric Blake wrote: > b.size() is atypical, Python programmers generally expect to be able > to do len(b). Keep the old spelling for backwards compatibility. > --- > generator/Python.ml | 4 > python/t/580-aio-is-zero.py | 2 ++ > 2 files chang

Re: [Libguestfs] [libnbd PATCH v3 3/5] python: Accept all buffer-like objects in aio_p{read, write}

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 08:34:45AM -0500, Eric Blake wrote: > After the work in the previous patches, it is now a trivial feature > addition to support any buffer-like object as the argument to > h.aio_{pread,pwrite}, and matching how h.pwrite already did that. For > example, you can do h.aio_pwri

Re: [Libguestfs] [libnbd PATCH v3 2/5] python: Alter lock for persistent buffer

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 08:34:44AM -0500, Eric Blake wrote: > As long as we were wrapping a C buffer and not leaking any Python > objects, we had to lock the nbd.Buffer object, to ensure that the > PyCapsule was not released prematurely, as there was nothing else to > hold on to. But now that the

Re: [Libguestfs] [libnbd PATCH 3/2] python: Slice pread_structured buffer from original

2022-06-09 Thread Eric Blake
On Tue, May 31, 2022 at 07:24:03PM -0500, Eric Blake wrote: > On Wed, Jun 01, 2022 at 02:20:48AM +0300, Nir Soffer wrote: > > On Tue, May 31, 2022 at 6:52 PM Eric Blake wrote: > > > > > > On Tue, May 31, 2022 at 10:49:03AM -0500, Eric Blake wrote: > > > > This patch fixes the corner-case regressio

Re: [Libguestfs] [libnbd PATCH v3 1/5] python: Simplify passing of mutable *error to callbacks

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 08:34:43AM -0500, Eric Blake wrote: > Instead of open-coding our code to create a PyObject wrapper of the > mutable *error to be passed to each callback, extract this into a > helper function. We can then slightly optimize things to hang on to a > single pointer to the ctyp

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Daniel P . Berrangé
On Thu, Jun 09, 2022 at 03:08:51PM +0100, Richard W.M. Jones wrote: > On Thu, Jun 09, 2022 at 02:14:07PM +0100, Daniel P. Berrangé wrote: > > If you can get the test to core dump, then plain old GDB core > > dump could also be useful - might identify which specific API > > is being called, which ca

Re: [Libguestfs] [v2v PATCH 4/4] convert_linux: install the QEMU guest agent with a firstboot script

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 03:53:39PM +0200, Laszlo Ersek wrote: > On 06/09/22 15:10, Laszlo Ersek wrote: > > > nm-online -x -q || > > ( > > systemctl -q is-active systemd-networkd && > > /usr/lib/systemd/systemd-networkd-wait-online -q --timeout=30 > > ) > > > > If the final exit status is nonz

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 02:14:07PM +0100, Daniel P. Berrangé wrote: > Setting GODEBUG=cgocheck=1 or GODEBUG=cgocheck=2 can sometimes > get more info. Took me a while to work out that we are actually setting that already (in ./run) which explains a couple of things: why I couldn't reproduce the

Re: [Libguestfs] [v2v PATCH 4/4] convert_linux: install the QEMU guest agent with a firstboot script

2022-06-09 Thread Laszlo Ersek
On 06/09/22 15:10, Laszlo Ersek wrote: > nm-online -x -q || > ( > systemctl -q is-active systemd-networkd && > /usr/lib/systemd/systemd-networkd-wait-online -q --timeout=30 > ) > > If the final exit status is nonzero, I think that's not a problem for > the firstboot script. > > The whole com

[Libguestfs] [libnbd PATCH v3 0/5] python: Speed up [aio_]pread_structured

2022-06-09 Thread Eric Blake
Less copying is always better. But I was quite surprised by some of my test cases in trying to prove that I had speedups; there's a huge difference between: for i in range(size // m): buf = h.pread_structured(m, m*i, f) and for i in range(size // m): buf = h.pread_structured(m, m*i, f) bu

[Libguestfs] [libnbd PATCH v3 1/5] python: Simplify passing of mutable *error to callbacks

2022-06-09 Thread Eric Blake
Instead of open-coding our code to create a PyObject wrapper of the mutable *error to be passed to each callback, extract this into a helper function. We can then slightly optimize things to hang on to a single pointer to the ctypes module, rather than looking it up on every callback. The generat

[Libguestfs] [libnbd PATCH v3 5/5] python: Slice structured read callback buffer from original

2022-06-09 Thread Eric Blake
The Py_BuildValue "y#" format copies data; this is because Python assumes our C memory can go out of scope, while the user's python callback can stash off whatever bytearray object it got. But this copying is inefficient. Now that we already have a Python buffer-like object in scope for the durat

[Libguestfs] [libnbd PATCH v3 4/5] python: Support len(nbd.Buffer(n))

2022-06-09 Thread Eric Blake
b.size() is atypical, Python programmers generally expect to be able to do len(b). Keep the old spelling for backwards compatibility. --- generator/Python.ml | 4 python/t/580-aio-is-zero.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/generator/Python.ml b/generator/Python

[Libguestfs] [libnbd PATCH v3 3/5] python: Accept all buffer-like objects in aio_p{read, write}

2022-06-09 Thread Eric Blake
After the work in the previous patches, it is now a trivial feature addition to support any buffer-like object as the argument to h.aio_{pread,pwrite}, and matching how h.pwrite already did that. For example, you can do h.aio_pwrite(b'123', 0), instead of having to copy into nbd.Buffer first. Mor

[Libguestfs] [libnbd PATCH v3 2/5] python: Alter lock for persistent buffer

2022-06-09 Thread Eric Blake
As long as we were wrapping a C buffer and not leaking any Python objects, we had to lock the nbd.Buffer object, to ensure that the PyCapsule was not released prematurely, as there was nothing else to hold on to. But now that the previous commit (4f15d0e9) swapped to wrapping a Python bytearray ob

Re: [Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Daniel P . Berrangé
On Thu, Jun 09, 2022 at 02:03:04PM +0100, Richard W.M. Jones wrote: > make[2]: Entering directory '/home/rjones/d/libnbd/golang' > perl /home/rjones/d/libnbd/podwrapper.pl --section=3 --man libnbd-golang.3 \ > --html ../html/libnbd-golang.3.html \ > libnbd-golang.pod > /home/rjones/d/libnbd

Re: [Libguestfs] [v2v PATCH 4/4] convert_linux: install the QEMU guest agent with a firstboot script

2022-06-09 Thread Laszlo Ersek
On 06/07/22 14:59, Richard W.M. Jones wrote: > virt-p2v uses: > > nm-online -t 30 > > Apparently systemd-networkd (which I've never knowingly used) has > another command: > > /usr/lib/systemd/systemd-networkd-wait-online > > which ought to do the same thing. (It defaults to 120 second tim

[Libguestfs] libnbd golang failure on RISC-V

2022-06-09 Thread Richard W.M. Jones
make[2]: Entering directory '/home/rjones/d/libnbd/golang' perl /home/rjones/d/libnbd/podwrapper.pl --section=3 --man libnbd-golang.3 \ --html ../html/libnbd-golang.3.html \ libnbd-golang.pod /home/rjones/d/libnbd/run go build write of Go pointer 0x3fa8028000 to non-Go memory 0x3fd2c0fb20 f

Re: [Libguestfs] [guestfs-tools PATCH] customize: rebase to the common/mlcustomize/Guest_packages interface

2022-06-09 Thread Laszlo Ersek
On 06/07/22 15:09, Richard W.M. Jones wrote: > This patch and the companion patch to libguestfs-common: > > Reviewed-by: Richard W.M. Jones Commit 7eb1ecf467e8 (with the submodule checkout hash refreshed to 9e990f3e4530). Thanks! Laszlo ___ Libguestfs

Re: [Libguestfs] [libguestfs-common PATCH] mlcustomize: factor out pkg install/update/uninstall from guestfs-tools

2022-06-09 Thread Laszlo Ersek
On 06/06/22 16:20, Laszlo Ersek wrote: > Factor the following internal functions from "guestfs-tools/customize" at > commit 40b28512f700 ("Version 1.49.2.", 2022-05-26): > > - guest_install_command > - guest_update_command > - guest_uninstall_command > > into a new interface in "libguestfs-common

Re: [Libguestfs] [PATCH virt-v2v 0/3] tests: Add a phony Fedora image for testing

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 11:58:32AM +0200, Laszlo Ersek wrote: > On 06/09/22 10:46, Richard W.M. Jones wrote: > > On Thu, Jun 09, 2022 at 10:25:08AM +0200, Laszlo Ersek wrote: > >> On 06/09/22 10:11, Richard W.M. Jones wrote: > >>> On Thu, Jun 09, 2022 at 10:02:54AM +0200, Laszlo Ersek wrote: >

Re: [Libguestfs] [PATCH virt-v2v 0/3] tests: Add a phony Fedora image for testing

2022-06-09 Thread Laszlo Ersek
On 06/09/22 10:46, Richard W.M. Jones wrote: > On Thu, Jun 09, 2022 at 10:25:08AM +0200, Laszlo Ersek wrote: >> On 06/09/22 10:11, Richard W.M. Jones wrote: >>> On Thu, Jun 09, 2022 at 10:02:54AM +0200, Laszlo Ersek wrote: On 06/08/22 18:48, Richard W.M. Jones wrote: > When we split virt-v

Re: [Libguestfs] [PATCH virt-v2v 0/3] tests: Add a phony Fedora image for testing

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 10:25:08AM +0200, Laszlo Ersek wrote: > On 06/09/22 10:11, Richard W.M. Jones wrote: > > On Thu, Jun 09, 2022 at 10:02:54AM +0200, Laszlo Ersek wrote: > >> On 06/08/22 18:48, Richard W.M. Jones wrote: > >>> When we split virt-v2v from libguestfs many moons ago, I copied the

Re: [Libguestfs] [PATCH virt-v2v 3/3] tests: Add test cases for converting the phony Fedora images

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 10:20:47AM +0200, Laszlo Ersek wrote: > On 06/08/22 18:49, Richard W.M. Jones wrote: > > As well as testing a full Fedora conversion which was not really > > tested properly before, this also adds tests of conversions of Btrfs, > > RAID and LUKS guests. > > --- > > tests/Ma

Re: [Libguestfs] [PATCH virt-v2v 0/3] tests: Add a phony Fedora image for testing

2022-06-09 Thread Laszlo Ersek
On 06/09/22 10:11, Richard W.M. Jones wrote: > On Thu, Jun 09, 2022 at 10:02:54AM +0200, Laszlo Ersek wrote: >> On 06/08/22 18:48, Richard W.M. Jones wrote: >>> When we split virt-v2v from libguestfs many moons ago, I copied the >>> test-data/ subdirectory over. I didn't modify it much, and it >>>

Re: [Libguestfs] [PATCH virt-v2v 3/3] tests: Add test cases for converting the phony Fedora images

2022-06-09 Thread Laszlo Ersek
On 06/08/22 18:49, Richard W.M. Jones wrote: > As well as testing a full Fedora conversion which was not really > tested properly before, this also adds tests of conversions of Btrfs, > RAID and LUKS guests. > --- > tests/Makefile.am | 8 ++ > tests/test-v2v-fedora-btr

Re: [Libguestfs] [PATCH virt-v2v 2/3] test-data/phony-guests: Allow virt-v2v to work against phony Fedora

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 10:13:52AM +0200, Laszlo Ersek wrote: > Looks OK to me, I just suggest using a different function name rather > than "basename". While the C code is certainly OK, conceptually we > already have two standard basename() functions, a POSIX compatible one > from , and a glibc (_

Re: [Libguestfs] [PATCH virt-v2v 2/3] test-data/phony-guests: Allow virt-v2v to work against phony Fedora

2022-06-09 Thread Laszlo Ersek
On 06/08/22 18:49, Richard W.M. Jones wrote: > We didn't use the phony Fedora guest before with virt-v2v (only the > phony Windows image). This commit makes miscellaneous changes so that > it can be used for testing: > > - Add dummy rpm and dracut commands. > > - Add dummy kernel, initramfs an

Re: [Libguestfs] [PATCH virt-v2v 0/3] tests: Add a phony Fedora image for testing

2022-06-09 Thread Richard W.M. Jones
On Thu, Jun 09, 2022 at 10:02:54AM +0200, Laszlo Ersek wrote: > On 06/08/22 18:48, Richard W.M. Jones wrote: > > When we split virt-v2v from libguestfs many moons ago, I copied the > > test-data/ subdirectory over. I didn't modify it much, and it > > contains much test data that is irrelevant to v

Re: [Libguestfs] [PATCH virt-v2v 2/3] test-data/phony-guests: Allow virt-v2v to work against phony Fedora

2022-06-09 Thread Richard W.M. Jones
On Wed, Jun 08, 2022 at 05:49:01PM +0100, Richard W.M. Jones wrote: > +# Virt-v2v also needs a kernel, initrd and modules path. > +$g->touch ("/boot/vmlinuz-$kver"); > +$g->touch ("/boot/initramfs-$kver.img"); > +$g->mkdir_p ("/lib/modules/$kver/kernel/drivers/block"); > +$g->upload ($ENV{SRCDIR}.'

Re: [Libguestfs] [PATCH virt-v2v 1/3] test-data/phony-guests: Increase size of root filesystem

2022-06-09 Thread Laszlo Ersek
On 06/08/22 18:49, Richard W.M. Jones wrote: > Avoid this error in virt-v2v when trying to convert the phony Fedora > guest image: > > [ 8.1] Checking for sufficient free disk space in the guest > virt-v2v: error: not enough free space for conversion on filesystem > ‘/’. 21.6 MB free < 100 MB n

Re: [Libguestfs] [PATCH virt-v2v 0/3] tests: Add a phony Fedora image for testing

2022-06-09 Thread Laszlo Ersek
On 06/08/22 18:48, Richard W.M. Jones wrote: > When we split virt-v2v from libguestfs many moons ago, I copied the > test-data/ subdirectory over. I didn't modify it much, and it > contains much test data that is irrelevant to virt-v2v. (This change > does _not_ clean up any of that ...) However