Occasionally this test will choose a random seed which results in an all-zeroes disk. The test tries to convert this to a compressed qcow2 file, and fails because no compressed clusters are detected in the resulting file. This happens because qcow2 stores zero clusters with a special sparse representation, they are never stored compressed, so a disk with only zeroes in it will never contain compressed clusters.
To fix this, detect an all-zeroes disk and skip. Reported-by: Eric Blake --- copy/copy-file-to-qcow2-compressed.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/copy/copy-file-to-qcow2-compressed.sh b/copy/copy-file-to-qcow2-compressed.sh index 018c8bba2f..2706eadd66 100755 --- a/copy/copy-file-to-qcow2-compressed.sh +++ b/copy/copy-file-to-qcow2-compressed.sh @@ -25,6 +25,7 @@ requires $QEMU_NBD --version requires nbdkit --exit-with-parent --version requires nbdkit sparse-random --dump-plugin requires qemu-img --version +requires nbdinfo --version #requires stat --version # Check the compress driver is supported by this qemu-nbd. @@ -45,6 +46,15 @@ cleanup_fn rm -f $file1 $file2 $out1 $out2 size=1G seed=$RANDOM +# Occasionally we will choose a seed which results in a completely +# empty file. Skip this case. +if nbdinfo --map --totals -- \ + [ nbdkit --exit-with-parent sparse-random $size seed=$seed ] | + grep -sq '100.0%.*hole,zero'; then + echo "$0: bad seed chosen, skipping the test" + exit 77 +fi + # Create a compressed qcow2 file1. # # sparse-random files should compress easily because by default each -- 2.41.0 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs