Description of problem: The virt-sparsify command fails when handling the qcow2 image on RHEL-AV compose. Version-Release number of selected component (if applicable): libguestfs-1.40.2-14.module+el8.2.0+4793+b09dd2fb.x86_64 qemu-kvm-4.2.0-4.module+el8.2.0+5220+e82621dc.x86_64 kernel-4.18.0-160.el8.x86_64 How reproducible: 100% Steps: 1. Install RHEL-AV related packages on rhel8.2 host 2. # qemu-img create -f qcow2 virt_tools.xfs.qcow2 200M 3. # guestfish -a virt_tools.xfs.qcow2 ><fs> run ><fs> pvcreate /dev/sda ><fs> vgcreate vol_test /dev/sda ><fs> lvcreate vol_file vol_test 190 ><fs> mkfs xfs /dev/vol_test/vol_file ><fs> vfs_type /dev/vol_test/vol_file xfs ><fs> mount /dev/vol_test/vol_file / ><fs> fill 1 93519872 /test ><fs> sync ><fs> rm /test ><fs> quit 4. # qemu-img info virt_tools.xfs.qcow2 image: virt_tools.xfs.qcow2 file format: qcow2 virtual size: 200 MiB (209715200 bytes) disk size: 95.4 MiB cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false 5. # virt-sparsify -x -v virt_tools.xfs.qcow2 outdisk 2>&1 | tee output.log 6. # qemu-img info outdisk image: outdisk file format: qcow2 virtual size: 200 MiB (209715200 bytes) disk size: 115 MiB cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false The qcow2 format image seems to not be sparsified. Actual results: The virt-sparsify command fails. Expected results: The virt-sparsify command should be able to deal with the qcow2 image successfully. Additional info:
Created attachment 1647576 [details] virt-sparsify log
Here's a smaller reproducer: $ qemu-img create -f qcow2 test1.qcow2 1G $ guestfish -a test1.qcow2 run : mkfs xfs /dev/sda : mount /dev/sda / : fill 1 100M /test : sync : rm /test $ virt-sparsify test1.qcow2 test2.qcow2 $ file test?.qcow2 test1.qcow2: QEMU QCOW2 Image (v3), 1073741824 bytes test2.qcow2: QEMU QCOW2 Image (v3), 1073741824 bytes $ ls -lh test?.qcow2 -rw-r--r--. 1 rjones rjones 111M Mar 2 12:37 test1.qcow2 -rw-r--r--. 1 rjones rjones 103M Mar 2 12:37 test2.qcow2 $ du -sh test?.qcow2 111M test1.qcow2 103M test2.qcow2 Using this we can more easily try different formats and filesystems. qcow2 xfs FAILS (see above) raw xfs OK qcow2 ext4 FAILS I was testing this with qemu-4.2.0-4.fc32.x86_64 I will need to go back to earlier versions of qemu to see if this ever worked before / what broke it.
This is weird, the bug only happens when the backend is libvirt (not direct). export LIBGUESTFS_BACKEND=direct "fixes" it ...
I couldn't find a way to reproduce this reliably. In particular the bug seemed to go away when I upgraded libvirt from 5.10 to 6.0. Which version of libvirt were you using for this test, and does it work with the latest libvirt in RHEL AV?
(In reply to Richard W.M. Jones from comment #3) > This is weird, the bug only happens when the backend is libvirt (not direct). > export LIBGUESTFS_BACKEND=direct "fixes" it ... Thanks for providing the simpler reproducer. I have tried and indeed the virt-sparsify command works when the backend is 'direct'. (In reply to Richard W.M. Jones from comment #4) > I couldn't find a way to reproduce this reliably. In particular the bug > seemed to go away when I upgraded libvirt from 5.10 to 6.0. Which > version of libvirt were you using for this test, and does it work > with the latest libvirt in RHEL AV? The libvirt version for test is 'libvirt-5.10.0-2.module+el8.2.0+5274+60f836b5.x86_64'. I upgraded libvirt to the latest version(libvirt-6.0.0-7.module+el8.2.0+5869+c23fe68b.x86_64), but failed to run the virt-sparsify command because of bug 1798148. Did you test on fedora 32? I use RHEL8.2 bare metal for this test.
(In reply to YongkuiGuo from comment #5) > The libvirt version for test is > 'libvirt-5.10.0-2.module+el8.2.0+5274+60f836b5.x86_64'. I upgraded libvirt > to the latest version(libvirt-6.0.0-7.module+el8.2.0+5869+c23fe68b.x86_64), > but failed to run the virt-sparsify command because of bug 1798148. > Did you test on fedora 32? I use RHEL8.2 bare metal for this test. I was using Fedora (Rawhide) but I had patched my copy of virt-sparsify with a non-upstream patch[1] that fixes the bug 1798148 problem. Because that is not an option for RHEL, I guess we will need to wait for that other bug to be fixed first. [1] https://www.redhat.com/archives/libguestfs/2020-February/msg00013.html
> I was using Fedora (Rawhide) but I had patched my copy of virt-sparsify > with a non-upstream patch[1] that fixes the bug 1798148 problem. Because > that is not an option for RHEL, I guess we will need to wait for that other > bug to be fixed first. > Ok, i get it.
Can not reproduce this issue with the latest libvirt version (libvirt-6.0.0-8, fixed version for bug 1798148). Steps: $ qemu-img create -f qcow2 test1.qcow2 1G $ guestfish -a test1.qcow2 run : mkfs xfs /dev/sda : mount /dev/sda / : fill 1 100M /test : sync : rm /test $ virt-sparsify test1.qcow2 test2.qcow2 $ du -sh test?.qcow2 114M test1.qcow2 4.2M test2.qcow2
So I also believe this is now fixed (I'm using libvirt-6.3.0-1.module+el8.3.0+6478+69f490bb.x86_64) Can we close this bug?
(In reply to Richard W.M. Jones from comment #9) > So I also believe this is now fixed (I'm using > libvirt-6.3.0-1.module+el8.3.0+6478+69f490bb.x86_64) > > Can we close this bug? Yes, I think we can close it.