iotests: add -io_uring support
cover iotests: add -io_uring support
Add support for block/blkio.c's "io_uring" block driver to qemu-iotests:
$ (cd build && tests/qemu-iotests/check -io_uring)
I took a look at supporting ./check -qcow2 -io_uring, but there are many failures related to test assumptions about image creation and QEMU command-line syntax. Only support testing raw images for now.
Stefan Hajnoczi (7):
block/blkio: add io_uring: filename parsing block/blkio: add "simple" creation support
iotests: string substitution order in _filter_img_create_filenames
iotests: filter img create backing_file when IMGPROTO is modified
iotests: add -io_uring support
iotests: add io_uring to supported protocols in 012
iotests: add io_uring to supported protocols in 052
block/blkio.c | 9 +++++++++ tests/qemu-iotests/012 | 2 +- tests/qemu-iotests/033 | 1 + tests/qemu-iotests/052 | 2 +- tests/qemu-iotests/197 | 4 +++- tests/qemu-iotests/197.out | 2 +- tests/qemu-iotests/215 | 4 +++- tests/qemu-iotests/215.out | 2 +- tests/qemu-iotests/check | 2 +- tests/qemu-iotests/common.filter | 10 +++++++++- tests/qemu-iotests/common.rc | 12 +++++++++++- 11 files changed, 41 insertions(+), 9 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/7 block/blkio: add io_uring: filename parsing
The qemu-iotests test suite requires filename parsing because it does not use image options syntax everywhere. Add it now so that later patches can enable qemu-iotests for the io_uring block driver.
The blkio.c code has other libblkio-based drivers that could benefit from filename parsing too. Leave them for now because I am not yet ready to add qemu-iotests support for them.
--- block/blkio.c | 7 +++++++ 1 file changed, 7 insertions(+)
block/blkio.c +7 -0
@@ -603,6 +603,12 @@ static void blkio_unregister_buf(BlockDriverState *bs, void *host, size_t size) } } +static void blkio_io_uring_parse_filename (const char *filename,QDict *options, +Error **errp) +{ +bdrv_parse_filename_strip_prefix (filename,"io_uring:" , options); +} +static int blkio_io_uring_open (BlockDriverState *bs,QDict *options,int flags,Error **errp) {
@@ -1049,6 +1055,7 @@ static BlockDriver bdrv_io_uring = { .format_name = "io_uring", .protocol_name = "io_uring", .bdrv_needs_filename = true, + .bdrv_parse_filename = blkio_io_uring_parse_filename, BLKIO_DRIVER_COMMON };
Signature · 1 line
2.41.0
PATCH 2/7 block/blkio: add "simple" creation support
In reply to Stefan HajnocziSome block drivers do not support image creation. This is inconvenient for test cases, which usually want to create an image before testing various I/O requests.
Use bdrv_co_create_opts_simple(), which initializes a pre-existing image instead of creating a new image, so that tests will be able to work with libblkio-based block drivers.
--- block/blkio.c | 2 ++ 1 file changed, 2 insertions(+)
block/blkio.c +2 -0
@@ -1032,6 +1032,8 @@ static void blkio_refresh_limits(BlockDriverState *bs, Error **errp) .instance_size = sizeof(BDRVBlkioState), \ .bdrv_file_open = blkio_file_open, \ .bdrv_close = blkio_close, \ + .bdrv_co_create_opts = bdrv_co_create_opts_simple, \ + .create_opts = &bdrv_create_opts_simple, \ .bdrv_co_getlength = blkio_co_getlength, \ .bdrv_co_truncate = blkio_truncate, \ .bdrv_co_get_info = blkio_co_get_info, \
Signature · 1 line
2.41.0
PATCH 3/7 iotests: string substitution order in _filter_img_create_filenames
In reply to Stefan Hajnoczi_filter_img_create_filenames fails to remove $IMGPROTO: when $REMOTE_TEST_DIR matches. echo "$IMGPROTO:$REMOTE_TEST_DIR" | _filter_img_create_filenames results in "$IMGPROTO:TEST_DIR" instead of "TEST_DIR".
Substitute "s#$REMOTE_TEST_DIR#TEST_DIR#g" after "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" since the latter matches $TEST_DIR. This way echo "$IMGPROTO:$REMOTE_TEST_DIR" | _filter_img_create_filenames results in "TEST_DIR" as expected.
--- tests/qemu-iotests/common.filter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/common.filter +1 -1
@@ -125,8 +125,8 @@ _filter_actual_image_size() _filter_img_create_filenames() { sed \ + -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ - -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ -e "s#$TEST_DIR#TEST_DIR#g" \ -e "s#$SOCK_DIR#SOCK_DIR#g" \ -e 's#SOCK_DIR/fuse-#TEST_DIR/#g' \
Signature · 1 line
2.41.0
PATCH 4/7 iotests: filter img create backing_file when IMGPROTO is modified
In reply to Stefan Hajnoczi197 and 215 modify IMGPROTO, IMGFMT, etc temporarily while creating an additional image file after the main test image. The backing file name still has the old IMGPROTO, IMGFMT, etc. This means _filter_img_create will not filter the backing_file= output from qemu-img.
Add a helper that filters backing_file= output so these test cases are more robust. This will be necessary in order to enable the io_uring protocol driver in qemu-iotests.
--- tests/qemu-iotests/197 | 4 +++- tests/qemu-iotests/197.out | 2 +- tests/qemu-iotests/215 | 4 +++- tests/qemu-iotests/215.out | 2 +- tests/qemu-iotests/common.filter | 8 ++++++++ 5 files changed, 16 insertions(+), 4 deletions(-)
tests/qemu-iotests/197 +3 -1
@@ -68,7 +68,9 @@ fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ - _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | \ + _filter_img_create_backing_file | \ + _filter_img_create $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io # Ensure that a read of two clusters, but where one is already allocated,
tests/qemu-iotests/197.out +1 -1
@@ -5,7 +5,7 @@ QA output created by 197 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 wrote 1024/1024 bytes at offset 3221225472 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT +Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=BACKING_FILE backing_fmt=IMGFMT wrote 65536/65536 bytes at offset 1048576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 131072/131072 bytes at offset 1048576
tests/qemu-iotests/215 +3 -1
@@ -65,7 +65,9 @@ fi _make_test_img 4G $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ - _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | \ + _filter_img_create_backing_file | \ + _filter_img_create $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io # Ensure that a read of two clusters, but where one is already allocated,
tests/qemu-iotests/215.out +1 -1
@@ -5,7 +5,7 @@ QA output created by 215 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 wrote 1024/1024 bytes at offset 3221225472 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT +Formatting 'TEST_DIR/t.wrap.IMGFMT', fmt=IMGFMT size=4294967296 backing_file=BACKING_FILE backing_fmt=IMGFMT wrote 65536/65536 bytes at offset 1048576 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 131072/131072 bytes at offset 1048576
tests/qemu-iotests/common.filter +8 -0
@@ -206,6 +206,14 @@ _filter_img_create() done } +# When creating additional images with different IMGPROTO, IMGFMT, etc than the +# main test image, _filter_img_create cannot filter backing_file since it +# contains different IMGPROTO, IMGFMT, etc values than currently in use. +_filter_img_create_backing_file() +{ + sed -e "s/ backing_file=[^ ]*/ backing_file=BACKING_FILE/g" +} + _filter_img_create_size() { gsed -e "s# size=[0-9]\\+# size=SIZE#g"
Signature · 1 line
2.41.0
PATCH 5/7 iotests: add -io_uring support
In reply to Stefan HajnocziThe libblkio-based io_uring block driver currently has no test coverage. Running existing qemu-iotests with io_uring is possible with just a few tweaks.
--- tests/qemu-iotests/033 | 1 + tests/qemu-iotests/check | 2 +- tests/qemu-iotests/common.rc | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-)
tests/qemu-iotests/033 +1 -0
@@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt generic _supported_proto generic +_unsupported_proto io_uring # libblkio 1.3.0 does not support write_zeroes with FUA _unsupported_imgopts "subformat=streamOptimized"
tests/qemu-iotests/check +1 -1
@@ -94,7 +94,7 @@ def make_argparser() -> argparse.ArgumentParser: mg.add_argument('-' + fmt, dest='imgfmt', action='store_const', const=fmt, help=f'test {fmt}') - protocol_list = ['file', 'rbd', 'nbd', 'ssh', 'nfs', 'fuse'] + protocol_list = ['file', 'rbd', 'nbd', 'ssh', 'nfs', 'fuse', 'io_uring'] g_prt = p.add_argument_group( ' image protocol options', 'The following options set the IMGPROTO environment variable. '
tests/qemu-iotests/common.rc +11 -1
@@ -290,6 +290,9 @@ if [ "$IMGOPTSSYNTAX" = "true" ]; then elif [ "$IMGPROTO" = "fuse" ]; then TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT TEST_IMG="$DRIVER,file.filename=$SOCK_DIR/fuse-t.$IMGFMT" + elif [ "$IMGPROTO" = "io_uring" ]; then + TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT + TEST_IMG="$DRIVER,file.driver=$IMGPROTO,file.filename=$TEST_DIR/t.$IMGFMT" elif [ "$IMGPROTO" = "ssh" ]; then TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT TEST_IMG="$DRIVER,file.driver=ssh,file.host=127.0.0.1,file.path=$TEST_IMG_FILE"
@@ -309,6 +312,9 @@ else elif [ "$IMGPROTO" = "fuse" ]; then TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT TEST_IMG="$SOCK_DIR/fuse-t.$IMGFMT" + elif [ "$IMGPROTO" = "io_uring" ]; then + TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT + TEST_IMG=io_uring:$TEST_DIR/t.$IMGFMT elif [ "$IMGPROTO" = "ssh" ]; then TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT REMOTE_TEST_DIR="ssh://\\($USER@\\)\\?127.0.0.1\\(:[0-9]\\+\\)\\?$TEST_DIR"
@@ -400,6 +406,10 @@ _test_img_to_test_img_file() echo "$1" | sed -e "s#$SOCK_DIR/fuse-#$TEST_DIR/#" ;; + io_uring) + echo "$1" | sed -e "s#io_uring:##" + ;; + nfs) echo "$1" | sed -e "s#nfs://127.0.0.1##" ;;
@@ -653,7 +663,7 @@ _cleanup_test_img() FUSE_EXPORTS=() ;; - file) + file|io_uring) _rm_test_img "$TEST_DIR/t.$IMGFMT" _rm_test_img "$TEST_DIR/t.$IMGFMT.orig" _rm_test_img "$TEST_DIR/t.$IMGFMT.base"
Signature · 1 line
2.41.0
PATCH 6/7 iotests: add io_uring to supported protocols in 012
In reply to Stefan Hajnoczi--- tests/qemu-iotests/012 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/012 +1 -1
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt generic -_supported_proto file +_supported_proto file io_uring # Remove once all tests are fixed to use TEST_IMG_FILE # correctly and common.rc sets it unconditionally
Signature · 1 line
2.41.0
PATCH 7/7 iotests: add io_uring to supported protocols in 052
In reply to Stefan Hajnoczi--- tests/qemu-iotests/052 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/052 +1 -1
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter _supported_fmt generic -_supported_proto file +_supported_proto file io_uring # Don't do O_DIRECT on tmpfs _supported_cache_modes writeback writethrough unsafe
Signature · 1 line
2.41.0