Description of problem: virt-sparsify doesn't work on RHEL-8.6 with the following error: ... qemu-img: /tmp/sparsify187700.qcow2: Backing file specified without backing format Detected format of qcow2.libguestfs: trace: disk_create = -1 (error) virt-sparsify: error: libguestfs error: qemu-img: /tmp/sparsify187700.qcow2: qemu-img exited with error status 1, see debug messages above Version-Release number of selected component (if applicable): libguestfs-1.44.0-3.module+el8.6.0+12648+6ede71a5.x86_64 qemu-kvm-6.1.0-1.module+el8.6.0+12648+6ede71a5.x86_64 How reproducible: 100% Steps: 1. On rhel8.6 host with RHEL-8.6.0-20211008.1 compose # wget http://download.eng.pek2.redhat.com/rhel-8/composes/RHEL-8/RHEL-8.6.0-20211008.1/compose/BaseOS/x86_64/images/rhel-guest-image-8.6-493.x86_64.qcow2 2. # virt-sparsify -v -x rhel-guest-image-8.6-493.x86_64.qcow2 outdisk libguestfs: trace: set_verbose true libguestfs: trace: set_verbose = 0 libguestfs: trace: disk_format "/home/git/libguestfs-ci/client/tests/libguestfs/rhel-guest-image-8.6-493.x86_64.qcow2" libguestfs: command: run: qemu-img --help | grep -sqE -- '\binfo\b.*-U\b' libguestfs: command: run: qemu-img libguestfs: command: run: \ info libguestfs: command: run: \ -U libguestfs: command: run: \ --output json libguestfs: command: run: \ /home/git/libguestfs-ci/client/tests/libguestfs/rhel-guest-image-8.6-493.x86_64.qcow2 libguestfs: parse_json: qemu-img info JSON output:\n{\n "virtual-size": 10737418240,\n "filename": "/home/git/libguestfs-ci/client/tests/libguestfs/rhel-guest-image-8.6-493.x86_64.qcow2",\n "cluster-size": 65536,\n "format": "qcow2",\n "actual-size": 779419648,\n "format-specific": {\n "type": "qcow2",\n "data": {\n "compat": "0.10",\n "compression-type": "zlib",\n "refcount-bits": 16\n }\n },\n "dirty-flag": false\n}\n\n libguestfs: trace: disk_format = "qcow2" libguestfs: trace: set_verbose true libguestfs: trace: set_verbose = 0 libguestfs: trace: disk_virtual_size "/home/git/libguestfs-ci/client/tests/libguestfs/rhel-guest-image-8.6-493.x86_64.qcow2" libguestfs: command: run: qemu-img --help | grep -sqE -- '\binfo\b.*-U\b' libguestfs: command: run: qemu-img libguestfs: command: run: \ info libguestfs: command: run: \ -U libguestfs: command: run: \ --output json libguestfs: command: run: \ /home/git/libguestfs-ci/client/tests/libguestfs/rhel-guest-image-8.6-493.x86_64.qcow2 libguestfs: parse_json: qemu-img info JSON output:\n{\n "virtual-size": 10737418240,\n "filename": "/home/git/libguestfs-ci/client/tests/libguestfs/rhel-guest-image-8.6-493.x86_64.qcow2",\n "cluster-size": 65536,\n "format": "qcow2",\n "actual-size": 779419648,\n "format-specific": {\n "type": "qcow2",\n "data": {\n "compat": "0.10",\n "compression-type": "zlib",\n "refcount-bits": 16\n }\n },\n "dirty-flag": false\n}\n\n libguestfs: trace: disk_virtual_size = 10737418240 input disk virtual size is 10737418240 bytes (10.0G) [ 0.0] Create overlay file in /tmp to protect source disk libguestfs: trace: set_verbose true libguestfs: trace: set_verbose = 0 libguestfs: trace: disk_create "/tmp/sparsify187700.qcow2" "qcow2" -1 "backingfile:/home/git/libguestfs-ci/client/tests/libguestfs/rhel-guest-image-8.6-493.x86_64.qcow2" "compat:1.1" libguestfs: command: run: qemu-img libguestfs: command: run: \ create libguestfs: command: run: \ -f qcow2 libguestfs: command: run: \ -o backing_file=/home/git/libguestfs-ci/client/tests/libguestfs/rhel-guest-image-8.6-493.x86_64.qcow2,compat=1.1 libguestfs: command: run: \ /tmp/sparsify187700.qcow2 qemu-img: /tmp/sparsify187700.qcow2: Backing file specified without backing format Detected format of qcow2.libguestfs: trace: disk_create = -1 (error) virt-sparsify: error: libguestfs error: qemu-img: /tmp/sparsify187700.qcow2: qemu-img exited with error status 1, see debug messages above libguestfs: trace: close libguestfs: closing guestfs handle 0x557cde3691a0 (state 0) libguestfs: trace: close libguestfs: closing guestfs handle 0x557cde367970 (state 0) libguestfs: trace: close libguestfs: closing guestfs handle 0x557cde366300 (state 0) Actual results: As above Expected results: virt-sparsify works on RHEL-8.6 as usual. Additional info: No this issue on RHEL-8.5 and RHEL-9.0
We'll need the same fix as: https://bugzilla.redhat.com/show_bug.cgi?id=1999419 (RHEL 9) https://bugzilla.redhat.com/show_bug.cgi?id=1998820 (upstream) Upstream fix is: https://github.com/libguestfs/libguestfs/commit/45de287447bb18d59749fbfc1ec5072413090109
Verified with package: libguestfs-1.44.0-4.module+el8.6.0+12969+f61072d9.x86_64 Steps: 1. On rhel8.6 host # wget http://download.eng.pek2.redhat.com/rhel-8/composes/RHEL-8/RHEL-8.6.0-20211008.1/compose/BaseOS/x86_64/images/rhel-guest-image-8.6-493.x86_64.qcow2 2. # virt-sparsify rhel-guest-image-8.6-493.x86_64.qcow2 outdisk [ 7.0] Fill free space in /dev/sda2 with zero [ 8.3] Fill free space in /dev/sda3 with zero [ 88.0] Copy to destination and make sparse [ 148.4] Sparsify operation completed with no errors. virt-sparsify: Before deleting the old disk, carefully check that the target disk boots and works correctly. virt-sparsify can be run successfully.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Moderate: virt:rhel and virt-devel:rhel security, bug fix, and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2022:1759