Skip to contentSkip to conversation

tests/qemu-iotests: Fix running with "check -ssh -qcow2"

PATCH Applied Thomas Huth 2 participants 11 messages Mar 15, 2024 – Mar 18, 2024

lore
Share & tools
lore
#0 lore raw

cover tests/qemu-iotests: Fix running with "check -ssh -qcow2"

I recently wanted to check for some changes that I did to the URI handling in the block layer code, but I had to discover that a lot of iotests only work with the raw file format when using a protocol that is not "file", i.e. "./check -ssh -qcow2" shows a lot of failures.
While some tests could be fixed to work with the "ssh" protocol, too, many other tests seem to be written for the "file" protocol only and thus have to be marked accordingly.

After applying these patches, there is still one failure left in test 181 where I'm unsure whether it's a real bug or whether this test should also simply be marked to work with the "file" protocol only. Suggestions are welcome!

Thomas Huth (9):
tests/qemu-iotests: Fix test 033 for running with non-file protocols tests/qemu-iotests: Restrict test 066 to the 'file' protocol tests/qemu-iotests: Restrict test 114 to the 'file' protocol tests/qemu-iotests: Restrict test 130 to the 'file' protocol tests/qemu-iotests: Restrict test 134 and 158 to the 'file' protocol tests/qemu-iotests: Restrict test 156 to the 'file' protocol tests/qemu-iotests: Restrict tests that use --image-opts to the 'file'
protocol
tests/qemu-iotests: Fix some tests that use --image-opts for other
protocols
tests/qemu-iotests: Restrict tests using "--blockdev file" to the file
protocol

 tests/qemu-iotests/033                                | 6 +++---
 tests/qemu-iotests/066                                | 2 +-
 tests/qemu-iotests/114                                | 2 +-
 tests/qemu-iotests/130                                | 2 +-
 tests/qemu-iotests/134                                | 2 +-
 tests/qemu-iotests/156                                | 2 +-
 tests/qemu-iotests/158                                | 2 +-
 tests/qemu-iotests/188                                | 2 +-
 tests/qemu-iotests/189                                | 2 +-
 tests/qemu-iotests/198                                | 2 +-
 tests/qemu-iotests/263                                | 6 ++++--
 tests/qemu-iotests/284                                | 7 +++----
 tests/qemu-iotests/tests/detect-zeroes-registered-buf | 4 +++-
 tests/qemu-iotests/tests/qcow2-internal-snapshots     | 2 +-
 tests/qemu-iotests/tests/qsd-jobs                     | 2 +-
 15 files changed, 24 insertions(+), 21 deletions(-)
Signature · 1 line
2.44.0
#1 lore raw

PATCH 1/9 tests/qemu-iotests: Fix test 033 for running with non-file protocols

When running iotest 033 with the ssh protocol, it fails with:

033 fail [14:48:31] [14:48:41] 10.2s output mismatch
--- /.../tests/qemu-iotests/033.out
+++ /.../tests/qemu-iotests/scratch/qcow2-ssh-033/033.out.bad
@@ -174,6 +174,7 @@
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 512/512 bytes at offset 2097152
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io: warning: Failed to truncate the tail of the image: ssh driver does not support shrinking files
read 512/512 bytes at offset 0
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)

We already check for the qcow2 format here, so let's simply also add a check for the protocol here, too, to only test the truncation with the file protocol.

---
 tests/qemu-iotests/033 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/qemu-iotests/033 +3 -3
index da9133c44b..4bc7a071bd 100755
@@ -123,9 +123,9 @@ do_test 512 "write -P 1 0 0x200" "$TEST_IMG" | _filter_qemu_io
 # next L2 table
 do_test 512 "write -P 1 $L2_COVERAGE 0x200" "$TEST_IMG" | _filter_qemu_io
 
-# only interested in qcow2 here; also other formats might respond with
-#  "not supported" error message
-if [ $IMGFMT = "qcow2" ]; then
+# only interested in qcow2 with file protocol here; also other formats
+# might respond with "not supported" error message
+if [ $IMGFMT = "qcow2" ] && [ $IMGPROTO = "file" ]; then
     do_test 512 "truncate $L2_COVERAGE" "$TEST_IMG" | _filter_qemu_io
 fi
 
Signature · 1 line
2.44.0
#2 lore raw

PATCH 2/9 tests/qemu-iotests: Restrict test 066 to the 'file' protocol

In reply to Thomas Huth

The hand-crafted json statement in this test only works if the test is run with the "file" protocol, so mark this test accordingly.

---
 tests/qemu-iotests/066 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/066 +1 -1
index cf63144cb9..336d8565dd 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # This tests qcow2-specific low-level functionality
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 # We need zero clusters and snapshots
 # (TODO: Consider splitting the snapshot part into a separate test
 #        file, so this one runs with refcount_bits=1 and data_file)
Signature · 1 line
2.44.0
#3 lore raw

PATCH 3/9 tests/qemu-iotests: Restrict test 114 to the 'file' protocol

In reply to Thomas Huth

iotest 114 uses "truncate" and the qcow2.py script on the destination file, which both cannot deal with URIs. Thus this test needs the "file" protocol, otherwise it fails with an error message like this:

truncate: cannot open 'ssh://127.0.0.1/tmp/qemu-build/tests/qemu-iotests/scratch/qcow2-ssh-114/t.qcow2.orig'
for writing: No such file or directory

Thus mark this test for "file protocol only" accordingly.

---
 tests/qemu-iotests/114 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/114 +1 -1
index de6fd327ee..dccc71008b 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 # At least OpenBSD doesn't seem to have truncate
 _supported_os Linux
 # qcow2.py does not work too well with external data files
Signature · 1 line
2.44.0
#4 lore raw

PATCH 4/9 tests/qemu-iotests: Restrict test 130 to the 'file' protocol

In reply to Thomas Huth

Using "-drive ...,backing.file.filename=..." only works with the file protocol, but not with URIs, so mark this test accordingly.

---
 tests/qemu-iotests/130 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/130 +1 -1
index 7257f09677..7af85d20a8 100755
@@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.qemu
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 # We are going to use lazy-refcounts
 _unsupported_imgopts 'compat=0.10'
Signature · 1 line
2.44.0
#5 lore raw

PATCH 5/9 tests/qemu-iotests: Restrict test 134 and 158 to the 'file' protocol

In reply to Thomas Huth

Commit b25b387fa592 updated the iotests 134 and 158 to use the --image-opts parameter for qemu-io with file protocol related options, but forgot to update the _supported_proto line accordingly. So let's do that now.

Fixes b25b387fa5 ("qcow2: convert QCow2 to use QCryptoBlock for encryption")
---
 tests/qemu-iotests/134 | 2 +-
 tests/qemu-iotests/158 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/qemu-iotests/134 +1 -1
index ded153c0b9..b2c3c03f08 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow qcow2
-_supported_proto generic
+_supported_proto file
 
 
 size=128M
tests/qemu-iotests/158 +1 -1
index a95878e4ce..3a9ad7eed0 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow qcow2
-_supported_proto generic
+_supported_proto file
 
 
 size=128M
Signature · 1 line
2.44.0
#6 lore raw

PATCH 6/9 tests/qemu-iotests: Restrict test 156 to the 'file' protocol

In reply to Thomas Huth

The test fails completely when you try to use it with a different protocol, e.g. with "./check -ssh -qcow2 156".
The test uses some hand-crafted JSON statements which cannot work with other protocols, thus let's change this test to only support the 'file' protocol.

---
 tests/qemu-iotests/156 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/156 +1 -1
index a9540bd80d..97c2d86ce5 100755
@@ -50,7 +50,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.qemu
 
 _supported_fmt qcow2 qed
-_supported_proto generic
+_supported_proto file
 # Copying files around with cp does not work with external data files
 _unsupported_imgopts data_file
 
Signature · 1 line
2.44.0
#7 lore raw

PATCH 7/9 tests/qemu-iotests: Restrict tests that use --image-opts to the 'file' protocol

In reply to Thomas Huth

These tests 188, 189 and 198 use qemu-io with --image-opts with additional hard-coded parameters for the file protocol, so they cannot work for other protocols. Thus we have to limit these tests to the file protocol only.

---
 tests/qemu-iotests/188 | 2 +-
 tests/qemu-iotests/189 | 2 +-
 tests/qemu-iotests/198 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/qemu-iotests/188 +1 -1
index ce087d1873..2950b1dc31 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _require_working_luks
 
tests/qemu-iotests/189 +1 -1
index 801494c6b9..008f73b07d 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _require_working_luks
 
tests/qemu-iotests/198 +1 -1
index 1c93dea1f7..6ddeffddd2 100755
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _require_working_luks
 
Signature · 1 line
2.44.0
#8 lore raw

PATCH 8/9 tests/qemu-iotests: Fix some tests that use --image-opts for other protocols

In reply to Thomas Huth

Tests 263, 284 and detect-zeroes-registered-buf use qemu-io with --image-opts so we have to enforce IMGOPTSSYNTAX=true here to get $TEST_IMG in shape for other protocols than "file".

---
 tests/qemu-iotests/263                                | 6 ++++--
 tests/qemu-iotests/284                                | 7 +++----
 tests/qemu-iotests/tests/detect-zeroes-registered-buf | 4 +++-
 3 files changed, 10 insertions(+), 7 deletions(-)
tests/qemu-iotests/263 +4 -2
index ec09b41405..44fdada0d6 100755
@@ -34,6 +34,8 @@ _cleanup()
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
+IMGOPTSSYNTAX=true
+
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
@@ -73,7 +75,7 @@ echo "testing LUKS qcow2 encryption"
 echo
 
 _make_test_img --object $SECRET -o "encrypt.format=luks,encrypt.key-secret=sec0,encrypt.iter-time=10,cluster_size=64K" $size
-_run_test "driver=$IMGFMT,encrypt.key-secret=sec0,file.filename=$TEST_IMG"
+_run_test "$TEST_IMG,encrypt.key-secret=sec0"
 _cleanup_test_img
 
 echo
@@ -82,7 +84,7 @@ echo
 
 
 _make_test_img --object $SECRET -o "encrypt.format=aes,encrypt.key-secret=sec0,cluster_size=64K" $size
-_run_test "driver=$IMGFMT,encrypt.key-secret=sec0,file.filename=$TEST_IMG"
+_run_test "$TEST_IMG,encrypt.key-secret=sec0"
 _cleanup_test_img
 
 
tests/qemu-iotests/284 +3 -4
index 5a82639e7f..722267486d 100755
@@ -33,6 +33,8 @@ _cleanup()
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
+IMGOPTSSYNTAX=true
+
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
@@ -47,14 +49,12 @@ size=1M
 
 SECRET="secret,id=sec0,data=astrochicken"
 
-IMGSPEC="driver=$IMGFMT,file.filename=$TEST_IMG,encrypt.key-secret=sec0"
 QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
 
 _run_test()
 {
-        IMGOPTSSYNTAX=true
         OLD_TEST_IMG="$TEST_IMG"
-        TEST_IMG="driver=$IMGFMT,file.filename=$TEST_IMG,encrypt.key-secret=sec0"
+        TEST_IMG="$TEST_IMG,encrypt.key-secret=sec0"
         QEMU_IMG_EXTRA_ARGS="--image-opts --object $SECRET"
 
         echo
@@ -78,7 +78,6 @@ _run_test()
 
         TEST_IMG="$OLD_TEST_IMG"
         QEMU_IMG_EXTRA_ARGS=
-        IMGOPTSSYNTAX=
 }
 
 
tests/qemu-iotests/tests/detect-zeroes-registered-buf +3 -1
index edb5f2cee5..5eaf34e5a6 100755
@@ -36,6 +36,8 @@ _cleanup()
 }
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
+IMGOPTSSYNTAX=true
+
 # get standard environment, filters and checks
 cd ..
 . ./common.rc
@@ -46,7 +48,7 @@ _supported_proto generic
 
 size=128M
 _make_test_img $size
-IMGSPEC="driver=$IMGFMT,file.filename=$TEST_IMG,discard=unmap,detect-zeroes=unmap"
+IMGSPEC="$TEST_IMG,discard=unmap,detect-zeroes=unmap"
 
 echo
 echo "== writing zero buffer to image =="
Signature · 1 line
2.44.0
#9 lore raw

PATCH 9/9 tests/qemu-iotests: Restrict tests using "--blockdev file" to the file protocol

In reply to Thomas Huth

Tests that use "--blockdev" with the "file" driver cannot work with other protocols, so we should mark them accordingly.

---
 tests/qemu-iotests/tests/qcow2-internal-snapshots | 2 +-
 tests/qemu-iotests/tests/qsd-jobs                 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/qemu-iotests/tests/qcow2-internal-snapshots +1 -1
index 36523aba06..9f83aa8903 100755
@@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # This tests qcow2-specific low-level functionality
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 # Internal snapshots are (currently) impossible with refcount_bits=1,
 # and generally impossible with external data files
 _unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file
tests/qemu-iotests/tests/qsd-jobs +1 -1
index 510bf0a9dc..9b843af631 100755
@@ -40,7 +40,7 @@ cd ..
 . ./common.filter
 
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 
 size=128M
 
Signature · 1 line
2.44.0
Applied
#10 lore raw
In reply to Thomas Huth

Am 15.03.2024 um 12:10 hat Thomas Huth geschrieben:

Quoted 13 lines

I recently wanted to check for some changes that I did to the URI handling in the block layer code, but I had to discover that a lot of iotests only work with the raw file format when using a protocol that is not "file", i.e. "./check -ssh -qcow2" shows a lot of failures.
While some tests could be fixed to work with the "ssh" protocol, too, many other tests seem to be written for the "file" protocol only and thus have to be marked accordingly.

After applying these patches, there is still one failure left in test 181 where I'm unsure whether it's a real bug or whether this test should also simply be marked to work with the "file" protocol only. Suggestions are welcome!

Quoted 13 lines

Thomas Huth (9):
tests/qemu-iotests: Fix test 033 for running with non-file protocols tests/qemu-iotests: Restrict test 066 to the 'file' protocol tests/qemu-iotests: Restrict test 114 to the 'file' protocol tests/qemu-iotests: Restrict test 130 to the 'file' protocol tests/qemu-iotests: Restrict test 134 and 158 to the 'file' protocol tests/qemu-iotests: Restrict test 156 to the 'file' protocol tests/qemu-iotests: Restrict tests that use --image-opts to the 'file'
protocol
tests/qemu-iotests: Fix some tests that use --image-opts for other
protocols
tests/qemu-iotests: Restrict tests using "--blockdev file" to the file
protocol

Thanks, applied to the block branch.

Kevin