Add cache mode option to qemu-iotests, and change default mode to "writeback"
v6 cover Add cache mode option to qemu-iotests, and change default mode to "writeback"
This series adds cache mode option in the iotests framework. Test cases are updated to make use of cache mode and mask supported modes.
v6: [05] Recover disappeared two lines. (Benoît)
Added Wenchao's reviewed-by lines to other patches.
v5: Fix help test for "-c mode". (Wenchao)
v4: Address Stefan's comments:
Add _default_cache_mode.
Split last two cases in 048 to 074.
Use long option "--cache" instead of "-t" for qemu-io.
v3: Change _unsupported_qemu_io_options to _supported_cache_modes.
Change default mode to "writeback".
Clean up some whitespaces in the end of series.
Fix "026.out.nocache" case.
Fix 048 case on tmpfs.
Fam Zheng (6):
qemu-iotests: Add "-c <cache-mode>" option
qemu-iotests: Honour cache mode in iotests.py
qemu-iotests: Add _default_cache_mode and _supported_cache_modes
qemu-iotests: Change default cache mode to "writeback"
qemu-iotests: Clean up spaces in usage output
qemu-iotests: Split qcow2 only cases in 048
tests/qemu-iotests/026 | 3 +- tests/qemu-iotests/039 | 3 +- tests/qemu-iotests/048 | 27 -------------- tests/qemu-iotests/048.out | 16 -------- tests/qemu-iotests/052 | 4 +- tests/qemu-iotests/074 | 86 +++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/074.out | 18 +++++++++ tests/qemu-iotests/check | 2 +- tests/qemu-iotests/common | 37 ++++++++++++++----- tests/qemu-iotests/common.rc | 25 ++++++++----- tests/qemu-iotests/iotests.py | 3 +- 11 files changed, 155 insertions(+), 69 deletions(-) create mode 100644 tests/qemu-iotests/074 create mode 100644 tests/qemu-iotests/074.out
Signature · 1 line
1.8.4.2
PATCH v6 1/6 qemu-iotests: Add "-c <cache-mode>" option
The option sets cache mode used in the tests. "-nocache" is changed to an alias to "-c none", and internally passes "-t none" to qemu-io.
Python scripts will make use of option this in the next commit.
--- tests/qemu-iotests/check | 2 +- tests/qemu-iotests/common | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-)
tests/qemu-iotests/check +1 -1
@@ -242,7 +242,7 @@ do fi reference=$seq.out - if (echo $QEMU_IO_OPTIONS | grep -s -- '--nocache' > /dev/null); then + if [ "$CACHEMODE" = "none" ]; then [ -f $seq.out.nocache ] && reference=$seq.out.nocache fi
tests/qemu-iotests/common +19 -2
@@ -42,13 +42,16 @@ expunge=true have_test_arg=false randomize=false valgrind=false +cachemode=false rm -f $tmp.list $tmp.tmp $tmp.sed export IMGFMT=raw export IMGFMT_GENERIC=true export IMGPROTO=file export IMGOPTS="" +export CACHEMODE="writethrough" export QEMU_IO_OPTIONS="" +export CACHEMODE_IS_DEFAULT=true for r do
@@ -113,7 +116,12 @@ s/ .*//p IMGOPTS="$r" imgopts=false continue - + elif $cachemode + then + CACHEMODE="$r" + CACHEMODE_IS_DEFAULT=false + cachemode=false + continue fi xpand=true
@@ -147,6 +155,7 @@ check options -o options -o options to pass to qemu-img create/convert -T output timestamps -r randomize test order + -c mode cache mode testlist options -g group[,group...] include tests from these groups
@@ -219,7 +228,8 @@ testlist options xpand=false ;; -nocache) - QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache" + CACHEMODE="none" + CACHEMODE_IS_DEFAULT=false xpand=false ;;
@@ -258,6 +268,10 @@ testlist options imgopts=true xpand=false ;; + -c) + cachemode=true + xpand=false + ;; -r) # randomize test order randomize=true xpand=false
@@ -334,6 +348,9 @@ BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ done +# Set qemu-io cache mode with $CACHEMODE we have +QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --cache $CACHEMODE" + # Set default options for qemu-img create -o if they were not specified _set_default_imgopts
Signature · 1 line
1.8.4.2
PATCH v6 2/6 qemu-iotests: Honour cache mode in iotests.py
In reply to Fam ZhengThis will allow overriding cache mode from the "-c mode" option.
--- tests/qemu-iotests/iotests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tests/qemu-iotests/iotests.py +2 -1
@@ -37,6 +37,7 @@ qemu_args = os.environ.get('QEMU', 'qemu').strip().split(' ') imgfmt = os.environ.get('IMGFMT', 'raw') imgproto = os.environ.get('IMGPROTO', 'file') test_dir = os.environ.get('TEST_DIR', '/var/tmp') +cachemode = os.environ.get('CACHEMODE') socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
@@ -96,7 +97,7 @@ class VM(object): '''Add a virtio-blk drive to the VM''' options = ['if=virtio', 'format=%s' % imgfmt, - 'cache=none', + 'cache=%s' % cachemode, 'file=%s' % path, 'id=drive%d' % self._num_drives] if opts:
Signature · 1 line
1.8.4.2
PATCH v6 3/6 qemu-iotests: Add _default_cache_mode and _supported_cache_modes
In reply to Fam ZhengThis replaces _unsupported_qemu_io_options and check for support of current cache mode, and allow to provide a default if user didn't specify.
--- tests/qemu-iotests/026 | 3 ++- tests/qemu-iotests/039 | 3 ++- tests/qemu-iotests/052 | 4 ++-- tests/qemu-iotests/common.rc | 25 +++++++++++++++---------- 4 files changed, 21 insertions(+), 14 deletions(-)
tests/qemu-iotests/026 +2 -1
@@ -44,7 +44,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _supported_os Linux - +_default_cache_mode "writethrough" +_supported_cache_modes "writethrough" "none" echo "Errors while writing 128 kB" echo
tests/qemu-iotests/039 +2 -1
@@ -44,7 +44,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _supported_os Linux -_unsupported_qemu_io_options --nocache +_default_cache_mode "writethrough" +_supported_cache_modes "writethrough" size=128M
tests/qemu-iotests/052 +2 -2
@@ -41,8 +41,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt generic _supported_proto generic _supported_os Linux -_unsupported_qemu_io_options --nocache - +_default_cache_mode "writethrough" +_supported_cache_modes "writethrough" size=128M _make_test_img $size
tests/qemu-iotests/common.rc +15 -10
@@ -387,18 +387,23 @@ _supported_os() _notrun "not suitable for this OS: $HOSTOS" } -_unsupported_qemu_io_options() +_supported_cache_modes() { - for bad_opt - do - for opt in $QEMU_IO_OPTIONS - do - if [ "$bad_opt" = "$opt" ] - then - _notrun "not suitable for qemu-io option: $bad_opt" - fi - done + for mode; do + if [ "$mode" = "$CACHEMODE" ]; then + return + fi done + _notrun "not suitable for cache mode: $CACHEMODE" +} + +_default_cache_mode() +{ + if $CACHEMODE_IS_DEFAULT; then + CACHEMODE="$1" + QEMU_IO="$QEMU_IO --cache $1" + return + fi } # this test requires that a specified command (executable) exists
Signature · 1 line
1.8.4.2
PATCH v6 4/6 qemu-iotests: Change default cache mode to "writeback"
In reply to Fam ZhengSo that the tests can run faster.
--- tests/qemu-iotests/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/common +1 -1
@@ -49,7 +49,7 @@ export IMGFMT=raw export IMGFMT_GENERIC=true export IMGPROTO=file export IMGOPTS="" -export CACHEMODE="writethrough" +export CACHEMODE="writeback" export QEMU_IO_OPTIONS="" export CACHEMODE_IS_DEFAULT=true
Signature · 1 line
1.8.4.2
PATCH v6 5/6 qemu-iotests: Clean up spaces in usage output
In reply to Fam ZhengWhitespace changes to align columns.
--- tests/qemu-iotests/common | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
tests/qemu-iotests/common +8 -8
@@ -132,7 +132,7 @@ s/ .*//p echo "Usage: $0 [options] [testlist]"' common options - -v verbose + -v verbose check options -raw test raw (default)
@@ -148,20 +148,20 @@ check options -sheepdog test sheepdog -nbd test nbd -ssh test ssh - -xdiff graphical mode diff - -nocache use O_DIRECT on backing file - -misalign misalign memory allocations - -n show me, do not run tests + -xdiff graphical mode diff + -nocache use O_DIRECT on backing file + -misalign misalign memory allocations + -n show me, do not run tests -o options -o options to pass to qemu-img create/convert - -T output timestamps - -r randomize test order + -T output timestamps + -r randomize test order -c mode cache mode testlist options -g group[,group...] include tests from these groups -x group[,group...] exclude tests from these groups NNN include test NNN - NNN-NNN include test range (eg. 012-021) + NNN-NNN include test range (eg. 012-021) ' exit 0 ;;
Signature · 1 line
1.8.4.2
Re: [Qemu-devel] [PATCH v6 5/6] qemu-iotests: Clean up spaces in usage output
Quoted 51 lines · Fam Zheng
Whitespace changes to align columns.
Signed-off-by Fam Zheng <[email protected]>--- tests/qemu-iotests/common | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)tests/qemu-iotests/common +8
-8@@ -132,7 +132,7 @@ s/ .*//p echo "Usage: $0 [options] [testlist]"' common options - -v verbose + -v verbose check options -raw test raw (default)@@ -148,20 +148,20 @@ check options -sheepdog test sheepdog -nbd test nbd -ssh test ssh - -xdiff graphical mode diff - -nocache use O_DIRECT on backing file - -misalign misalign memory allocations - -n show me, do not run tests + -xdiff graphical mode diff + -nocache use O_DIRECT on backing file + -misalign misalign memory allocations + -n show me, do not run tests -o options -o options to pass to qemu-img create/convert - -T output timestamps - -r randomize test order + -T output timestamps + -r randomize test order -c mode cache mode testlist options -g group[,group...] include tests from these groups -x group[,group...] exclude tests from these groups NNN include test NNN - NNN-NNN include test range (eg. 012-021) + NNN-NNN include test range (eg. 012-021) ' exit 0 ;;Signature · 1 line
1.8.4.2
First time I found a bug while reviewing !!
PATCH v6 6/6 qemu-iotests: Split qcow2 only cases in 048
In reply to Fam ZhengFormat "raw" doesn't always work on certain file systems (e.g. tmpfs). Use qcow2 to make the allocation status explicit and split into a new case.
--- tests/qemu-iotests/048 | 27 --------------- tests/qemu-iotests/048.out | 16 --------- tests/qemu-iotests/074 | 86 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/074.out | 18 ++++++++++ 4 files changed, 104 insertions(+), 43 deletions(-) create mode 100644 tests/qemu-iotests/074 create mode 100644 tests/qemu-iotests/074.out
tests/qemu-iotests/048 +0 -27
@@ -81,32 +81,5 @@ cp "$TEST_IMG" "$TEST_IMG2" io_pattern write 512 512 0 1 101 _compare -# Test cluster allocated in one, with IO error -cat > "$TEST_DIR/blkdebug.conf"<<EOF -[inject-error] -event = "read_aio" -errno = "5" -once ="off" -EOF -_make_test_img $size -cp "$TEST_IMG" "$TEST_IMG2" -io_pattern write 512 512 0 1 102 -TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\ - _filter_testdir | _filter_imgfmt - -# Test cluster allocated in one, with different sizes and IO error in the part -# that exists only in one image -cat > "$TEST_DIR/blkdebug.conf"<<EOF -[inject-error] -event = "read_aio" -errno = "5" -once ="off" -EOF -_make_test_img $size -TEST_IMG="$TEST_IMG2" _make_test_img 0 -io_pattern write 512 512 0 1 102 -TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" _compare 2>&1 |\ - _filter_testdir | _filter_imgfmt - # Cleanup status=0
tests/qemu-iotests/048.out +0 -16
@@ -37,20 +37,4 @@ qemu-io> wrote 512/512 bytes at offset 512 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) qemu-io> Content mismatch at offset 512! 1 -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 -=== IO: pattern 102 -qemu-io> wrote 512/512 bytes at offset 512 -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-io> qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error -qemu-img: Error while reading offset 0: Input/output error -4 -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 -Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=0 -=== IO: pattern 102 -qemu-io> wrote 512/512 bytes at offset 512 -512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-io> qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error -qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error -Warning: Image size mismatch! -4 Cleanup
tests/qemu-iotests/074 new file +86 -0
86 lines not on this page · raw message
tests/qemu-iotests/074.out new file +18 -0
@@ -0,0 +1,18 @@ +QA output created by 048 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 +=== IO: pattern 102 +qemu-io> wrote 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-io> qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error +qemu-img: Error while reading offset 0: Input/output error +4 +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 +Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=0 +=== IO: pattern 102 +qemu-io> wrote 512/512 bytes at offset 512 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-io> qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error +qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error +Warning: Image size mismatch! +4 +Cleanup
Signature · 1 line
1.8.4.2
PATCH 1/1 qemu-iotests: 074 fixups
A few things missing from the previous patch:
* add 074 to the group file
* label new output "074" instead of "048"
* remove "qemu-io> " prompts from output (qemu.git/master merge conflict)
---
Fam: can I squash these missing things into your patch?
tests/qemu-iotests/074 | 0 tests/qemu-iotests/074.out | 10 +++++----- tests/qemu-iotests/group | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) mode change 100644 => 100755 tests/qemu-iotests/074
tests/qemu-iotests/074 +0 -0
tests/qemu-iotests/074.out +5 -5
@@ -1,17 +1,17 @@ -QA output created by 048 +QA output created by 074 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 === IO: pattern 102 -qemu-io> wrote 512/512 bytes at offset 512 +wrote 512/512 bytes at offset 512 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-io> qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error +qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error qemu-img: Error while reading offset 0: Input/output error 4 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824 Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=0 === IO: pattern 102 -qemu-io> wrote 512/512 bytes at offset 512 +wrote 512/512 bytes at offset 512 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-io> qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error +qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error qemu-img: Error while reading offset 0 of blkdebug:TEST_DIR/blkdebug.conf:TEST_DIR/t.IMGFMT: Input/output error Warning: Image size mismatch! 4
tests/qemu-iotests/group +1 -0
@@ -77,3 +77,4 @@ 069 rw auto 070 rw auto 073 rw auto +074 rw auto
Signature · 1 line
1.8.4.2
Re: [Qemu-devel] [PATCH] qemu-iotests: 074 fixups
Quoted 10 lines · Stefan Hajnoczi
A few things missing from the previous patch:
* add 074 to the group file
* label new output "074" instead of "048"
* remove "qemu-io> " prompts from output (qemu.git/master merge conflict)Signed-off-by Stefan Hajnoczi <[email protected]>---
Fam: can I squash these missing things into your patch?
Of course. Thanks.
Fam
Stefan Hajnoczi
AppliedQuoted 28 lines · Fam Zheng
This series adds cache mode option in the iotests framework. Test cases are updated to make use of cache mode and mask supported modes.
v6: [05] Recover disappeared two lines. (Benoît)
Added Wenchao's reviewed-by lines to other patches.v5: Fix help test for "-c mode". (Wenchao)
v4: Address Stefan's comments:
Add_default_cache_mode.
Split last two cases in 048 to 074.
Use long option "--cache" instead of "-t" for qemu-io.v3: Change
_unsupported_qemu_io_optionsto_supported_cache_modes.
Change default mode to "writeback".
Clean up some whitespaces in the end of series.
Fix "026.out.nocache" case.
Fix 048 case on tmpfs.Fam Zheng (6):
qemu-iotests: Add "-c <cache-mode>" option
qemu-iotests: Honour cache mode iniotests.py
qemu-iotests: Add_default_cache_modeand_supported_cache_modes
qemu-iotests: Change default cache mode to "writeback"
qemu-iotests: Clean up spaces in usage output
qemu-iotests: Split qcow2 only cases in 048
Quoted 14 lines
tests/qemu-iotests/026 | 3 +- tests/qemu-iotests/039 | 3 +- tests/qemu-iotests/048 | 27 -------------- tests/qemu-iotests/048.out | 16 -------- tests/qemu-iotests/052 | 4 +- tests/qemu-iotests/074 | 86 +++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/074.out | 18 +++++++++ tests/qemu-iotests/check | 2 +- tests/qemu-iotests/common | 37 ++++++++++++++----- tests/qemu-iotests/common.rc | 25 ++++++++----- tests/qemu-iotests/iotests.py | 3 +- 11 files changed, 155 insertions(+), 69 deletions(-) create mode 100644 tests/qemu-iotests/074 create mode 100644 tests/qemu-iotests/074.out
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan