Add cache mode option to qemu-iotests, and change default mode to "writeback"
v4 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.
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 v4 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 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
Re: [Qemu-devel] [PATCH v4 1/6] qemu-iotests: Add "-c <cache-mode>" option
tests/qemu-iotests/common check options · line 159
Quoted 7 lines
xpand=true
tests/qemu-iotests/common +1
-0@@ -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 cache mode
"+ -c mode cache mode"?
Re: [Qemu-devel] [PATCH v4 1/6] qemu-iotests: Add "-c <cache-mode>" option
Quoted 10 lines · Wenchao Xia
tests/qemu-iotests/common check options · line 159
Quoted 7 lines
xpand=true
tests/qemu-iotests/common +1
-0@@ -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 cache mode"+ -c mode cache mode"?
Yes, good idea.
Fam
PATCH v4 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
Re: [Qemu-devel] [PATCH v4 2/6] qemu-iotests: Honour cache mode in iotests.py
PATCH v4 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
Re: [Qemu-devel] [PATCH v4 3/6] qemu-iotests: Add _default_cache_mode and _supported_cache_modes
This patch override only when default is specified, I am +1 with it. I think we had discuss before, just want a double check, stefan, do you agree with this?
Quoted 17 lines
This replaces
_unsupported_qemu_io_optionsand check for support of current cache mode, and allow to provide a default if user didn't specify.Signed-off-by Fam Zheng <[email protected]>--- 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 +0
-0
tests/qemu-iotests/026 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 49
Quoted 7 lines
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"
Why forbid mode = writeback?
Quoted 7 lines
tests/qemu-iotests/026 +0
-0echo "Errors while writing 128 kB" echotests/qemu-iotests/039 +0
-0
tests/qemu-iotests/039 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 49
Quoted 7 lines
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"
same here.
Quoted 7 lines
tests/qemu-iotests/039 +0
-0size=128Mtests/qemu-iotests/052 +0
-0
tests/qemu-iotests/052 trap "_cleanup; exit \$status" 0 1 2 3 15 · line 46
Quoted 8 lines
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"
same question.
Quoted 41 lines
tests/qemu-iotests/052 +0
-0size=128M _make_test_img $sizetests/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
Re: [Qemu-devel] [PATCH v4 3/6] qemu-iotests: Add _default_cache_mode and _supported_cache_modes
Quoted 3 lines · Wenchao Xia
Why forbid mode = writeback?
These test cases used to run with only possibly "writethrough", or "none". And they don't work with writeback, at least in my case. So I didn't add other modes here.
Fam
Re: [Qemu-devel] [PATCH v4 3/6] qemu-iotests: Add _default_cache_mode and _supported_cache_modes
Am 03.12.2013 um 09:21 hat Fam Zheng geschrieben:
Quoted 9 lines · Wenchao Xia
Quoted 4 lines
Why forbid mode = writeback?
These test cases used to run with only possibly "writethrough", or "none". And they don't work with writeback, at least in my case. So I didn't add other modes here.
I suspect that the tests allowing writethrough might also work with directsync. Did you give that one a try?
026 has different output for wt and wb modes, this is why writeback fails. It should probably check against 026.out.nocache (which would have to be renamed as 026.out.wb) instead of 026.out. That's something for a separate series, though.
Kevin
Re: [Qemu-devel] [PATCH v4 3/6] qemu-iotests: Add _default_cache_mode and _supported_cache_modes
Quoted 7 lines · Kevin Wolf
Am 03.12.2013 um 09:21 hat Fam Zheng geschrieben:
Quoted 6 lines · Wenchao Xia
Quoted 4 lines
Why forbid mode = writeback?
Quoted 7 lines
Quoted 3 lines
These test cases used to run with only possibly "writethrough", or "none". And they don't work with writeback, at least in my case. So I didn't add other modes here.
I suspect that the tests allowing writethrough might also work with directsync. Did you give that one a try?
I guess so. Except for my /tmp is tmpfs and complains about O_DIRECT. It works for me with "TMPDIR=/var/tmp".
Quoted 5 lines
026 has different output for wt and wb modes, this is why writeback fails. It should probably check against 026.out.nocache (which would have to be renamed as 026.out.wb) instead of 026.out. That's something for a separate series, though.
Yes, good idea. I'll do this and the directsync including in the next series.
Fam
Re: [Qemu-devel] [PATCH v4 3/6] qemu-iotests: Add _default_cache_mode and _supported_cache_modes
In reply to Wenchao XiaQuoted 3 lines · Wenchao Xia
This patch override only when default is specified, I am +1 with it. I think we had discuss before, just want a double check, stefan, do you agree with this?
Yes, I'm happy with this.
I just want to avoid test cases with custom code that silently changes settings. As long as the default cache mode is declarative it's fine:_default_cache_mode "writethrough"
PATCH v4 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
Re: [Qemu-devel] [PATCH v4 4/6] qemu-iotests: Change default cache mode to "writeback"
PATCH v4 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 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 v4 5/6] qemu-iotests: Clean up spaces in usage output
PATCH v4 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
Am 26.11.2013 um 02:43 hat Fam Zheng geschrieben:
Quoted 23 lines
This series adds cache mode option in the iotests framework. Test cases are updated to make use of cache mode and mask supported modes.
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