On Mon, Mar 03, 2025 at 04:41:56PM +0800, Stefan Hajnoczi wrote: > On Fri, Feb 28, 2025 at 09:57:08PM +0200, Nir Soffer wrote: > > This test depends on TarFile.addfile() to add tar member header without > > writing the member data, which we write ourself using qemu-nbd. Python > > 3.13 changed the function in a backward incompatible way[1] to require a > > file object for tarinfo with non-zero size, breaking the test: > > > > -[{"name": "vm.ovf", "offset": 512, "size": 6}, {"name": "disk", > > "offset": 1536, "size": 393216}] > > +Traceback (most recent call last): > > + File "/home/stefanha/qemu/tests/qemu-iotests/302", line 118, in > > <module> > > + tar.addfile(disk) > > + ~~~~~~~~~~~^^^^^^ > > + File "/usr/lib64/python3.13/tarfile.py", line 2262, in addfile > > + raise ValueError("fileobj not provided for non zero-size regular > > file") > > +ValueError: fileobj not provided for non zero-size regular file > > > > The new behavior makes sense for most users, but breaks our unusual > > usage. Fix the test to add the member header directly using public but > > undocumented attributes. This is more fragile but the test works again. > > > > This also fixes a bug in the previous code - when calling addfile() > > without a fileobject, tar.offset points to the start of the member data > > instead of the end. > > > > [1] https://github.com/python/cpython/pull/117988 > > > > Signed-off-by: Nir Soffer <nir...@gmail.com> > > --- > > tests/qemu-iotests/302 | 19 ++++++++++++++----- > > 1 file changed, 14 insertions(+), 5 deletions(-) > > Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
Added to my NBD queue. -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org