Improve I/O tests coverage of LUKS driver
PATCH v6 1/5 iotests: skip 159 & 170 with luks format
In reply to Daniel P. BerrangeWhile the qemu-img dd command does accept --image-opts this is not sufficient to make it work with the LUKS image yet. This is because bdrv_create() still always requires the non-image-opts syntax.
Thus we must skip 159/170 with luks for now
--- tests/qemu-iotests/159 | 1 + tests/qemu-iotests/170 | 1 + 2 files changed, 2 insertions(+)
tests/qemu-iotests/159 +1 -0
@@ -40,6 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt generic _supported_proto file _supported_os Linux +_unsupported_fmt luks TEST_SIZES="5 512 1024 1999 1K 64K 1M"
tests/qemu-iotests/170 +1 -0
@@ -40,6 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt generic _supported_proto file _supported_os Linux +_unsupported_fmt luks echo echo "== Creating image =="
Signature · 1 line
2.9.3
v6 cover Improve I/O tests coverage of LUKS driver
The main goal of this series is to get the I/O tests passing 100% with LUKS when run with './check -luks'. It also adds a few more combinations to the LUKS/dmcrypt interoperability test.
To make LUKS testing not quite as slow, we drop the PBKDF iteration count down to a very small value. This doesn't remove all overhead, as formatting the volume will always measure PBKDF timing over a 1 second interval.
Changed in v6:
- Fix quoting of $TEST_IMG (Eric/Max)
- Remove accidental use of tabs (Max)
- Drop unused SYSEMU_EXTRA_ARGS (Max)
- Remove accidental import of 'time' module (Max)
Changed in v5:
- Rebase to kevin/block git tree instead of master
- Fix LUKS compat in new test 181
Changed in v4:
- Fix misc mistakes in syntax conversion (Max)
- Drop changes to 120 & mark it unsupported (Max)
- Use _unsupported_fmt (Max)
Changed in v3:
- Fix some typos in commit message(s) (Eric)
Changed in v2:
- Split off patch that change check.time recording since it was not a direct dependancy
- Skip new 159 & 170 tests which don't work due to qemu-img dd limitations
Daniel P. Berrange (5):
iotests: skip 159 & 170 with luks format
iotests: fix remainining tests to work with LUKS
iotests: reduce PBKDF iterations when testing LUKS
iotests: add more LUKS hash combination tests
iotests: chown LUKS device before qemu-io launches
tests/qemu-iotests/033 | 12 +- tests/qemu-iotests/120 | 1 + tests/qemu-iotests/140 | 9 +- tests/qemu-iotests/145 | 19 +- tests/qemu-iotests/149 | 25 +- tests/qemu-iotests/149.out | 1002 ++++++++++++++++++++++++++++---------- tests/qemu-iotests/157 | 17 +- tests/qemu-iotests/157.out | 16 +- tests/qemu-iotests/159 | 1 + tests/qemu-iotests/170 | 1 + tests/qemu-iotests/174 | 2 +- tests/qemu-iotests/181 | 21 +- tests/qemu-iotests/common.filter | 3 +- tests/qemu-iotests/common.qemu | 9 +- tests/qemu-iotests/common.rc | 3 + 15 files changed, 841 insertions(+), 300 deletions(-)
Signature · 1 line
2.9.3
PATCH v6 2/5 iotests: fix remainining tests to work with LUKS
The tests 033, 140, 145 and 157 were all broken when run with LUKS, since they did not correctly use the required image opts args syntax to specify the decryption secret. Further, the 120 test simply does not make sense to run with luks, as the scenario exercised is not relevant.
The test 181 was broken when run with LUKS because it didn't take account of fact that $TEST_IMG was already in image opts syntax. The launch_qemu helper also didn't register the secret object providing the LUKS password.
--- tests/qemu-iotests/033 | 12 ++++++++++-- tests/qemu-iotests/120 | 1 + tests/qemu-iotests/140 | 9 ++++++++- tests/qemu-iotests/145 | 19 +++++++++++++++++-- tests/qemu-iotests/157 | 17 ++++++++++++++--- tests/qemu-iotests/157.out | 16 ++++++++-------- tests/qemu-iotests/174 | 2 +- tests/qemu-iotests/181 | 21 ++++++++++++++++----- tests/qemu-iotests/common.qemu | 9 +++++++-- 9 files changed, 82 insertions(+), 24 deletions(-)
tests/qemu-iotests/033 +10 -2
@@ -50,10 +50,18 @@ do_test() local align=$1 local iocmd=$2 local img=$3 + if [ "$IMGOPTSSYNTAX" = "true" ] + then + IO_OPEN_ARG="$img" + IO_EXTRA_ARGS="--image-opts" + else + IO_OPEN_ARG="-o driver=$IMGFMT,file.align=$align blkdebug::$img" + IO_EXTRA_ARGS="" + fi { - echo "open -o driver=$IMGFMT,file.align=$align blkdebug::$img" + echo "open $IO_OPEN_ARG" echo $iocmd - } | $QEMU_IO + } | $QEMU_IO $IO_EXTRA_ARGS } for write_zero_cmd in "write -z" "aio_write -z"; do
tests/qemu-iotests/120 +1 -0
@@ -41,6 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt generic _supported_proto file _supported_os Linux +_unsupported_fmt luks _make_test_img 64M
tests/qemu-iotests/140 +8 -1
@@ -52,8 +52,15 @@ _make_test_img 64k $QEMU_IO -c 'write -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io +if test "$IMGOPTSSYNTAX" = "true" +then + SYSEMU_DRIVE_ARG=if=none,media=cdrom,id=drv,"$TEST_IMG" +else + SYSEMU_DRIVE_ARG=if=none,media=cdrom,id=drv,file="$TEST_IMG",driver=$IMGFMT +fi + keep_stderr=y \ -_launch_qemu -drive if=none,media=cdrom,id=drv,file="$TEST_IMG",format=$IMGFMT \ +_launch_qemu -drive $SYSEMU_DRIVE_ARG \ 2> >(_filter_nbd) _send_qemu_cmd $QEMU_HANDLE \
tests/qemu-iotests/145 +17 -2
@@ -43,8 +43,23 @@ _supported_proto generic _supported_os Linux _make_test_img 1M -echo quit | $QEMU -nographic -hda "$TEST_IMG" -incoming 'exec:true' -snapshot -serial none -monitor stdio | - _filter_qemu | _filter_hmp + +if test "$IMGOPTSSYNTAX" = "true" +then + SYSEMU_DRIVE_ARG=if=none,$TEST_IMG + SYSEMU_EXTRA_ARGS="" + if [ -n "$IMGKEYSECRET" ]; then + SECRET_ARG="secret,id=keysec0,data=$IMGKEYSECRET" + SYSEMU_EXTRA_ARGS="-object $SECRET_ARG" + fi +else + SYSEMU_DRIVE_ARG=if=none,file="$TEST_IMG",driver=$IMGFMT + SYSEMU_EXTRA_ARGS="" +fi + +echo quit | $QEMU -nographic $SYSEMU_EXTRA_ARGS -drive $SYSEMU_DRIVE_ARG \ + -incoming 'exec:true' -snapshot -serial none -monitor stdio \ + | _filter_qemu | _filter_hmp # success, all done echo "*** done"
tests/qemu-iotests/157 +14 -3
@@ -43,7 +43,6 @@ _supported_os Linux function do_run_qemu() { - echo Testing: "$@" ( if ! test -t 0; then while read cmd; do
@@ -63,7 +62,18 @@ function run_qemu() size=128M -drive="if=none,file=$TEST_IMG,driver=$IMGFMT" +if test "$IMGOPTSSYNTAX" = "true" +then + SYSEMU_DRIVE_ARG=if=none,$TEST_IMG + SYSEMU_EXTRA_ARGS="" + if [ -n "$IMGKEYSECRET" ]; then + SECRET_ARG="secret,id=keysec0,data=$IMGKEYSECRET" + SYSEMU_EXTRA_ARGS="-object $SECRET_ARG" + fi +else + SYSEMU_DRIVE_ARG=if=none,file="$TEST_IMG",driver=$IMGFMT + SYSEMU_EXTRA_ARGS="" +fi _make_test_img $size
@@ -76,8 +86,9 @@ echo for cache in "writeback" "writethrough"; do for wce in "" ",write-cache=auto" ",write-cache=on" ",write-cache=off"; do + echo "Testing: cache='$cache' wce='$wce'" echo "info block" \ - | run_qemu -drive "$drive,cache=$cache" \ + | run_qemu $SYSEMU_EXTRA_ARGS -drive "$SYSEMU_DRIVE_ARG,cache=$cache" \ -device "virtio-blk,drive=none0$wce" \ | grep -e "Testing" -e "Cache mode" done
tests/qemu-iotests/157.out +8 -8
@@ -3,20 +3,20 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 === Setting WCE with qdev and with manually created BB === -Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writeback -device virtio-blk,drive=none0 +Testing: cache='writeback' wce='' Cache mode: writeback -Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writeback -device virtio-blk,drive=none0,write-cache=auto +Testing: cache='writeback' wce=',write-cache=auto' Cache mode: writeback -Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writeback -device virtio-blk,drive=none0,write-cache=on +Testing: cache='writeback' wce=',write-cache=on' Cache mode: writeback -Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writeback -device virtio-blk,drive=none0,write-cache=off +Testing: cache='writeback' wce=',write-cache=off' Cache mode: writethrough -Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writethrough -device virtio-blk,drive=none0 +Testing: cache='writethrough' wce='' Cache mode: writethrough -Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writethrough -device virtio-blk,drive=none0,write-cache=auto +Testing: cache='writethrough' wce=',write-cache=auto' Cache mode: writethrough -Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writethrough -device virtio-blk,drive=none0,write-cache=on +Testing: cache='writethrough' wce=',write-cache=on' Cache mode: writeback -Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writethrough -device virtio-blk,drive=none0,write-cache=off +Testing: cache='writethrough' wce=',write-cache=off' Cache mode: writethrough *** done
tests/qemu-iotests/174 +1 -1
@@ -41,7 +41,7 @@ _unsupported_fmt raw size=256K -IMGFMT=raw IMGOPTS= _make_test_img $size | _filter_imgfmt +IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt echo echo "== reading wrong format should fail =="
tests/qemu-iotests/181 +16 -5
@@ -55,13 +55,24 @@ echo qemu_comm_method="monitor" -_launch_qemu \ - -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk +if [ "$IMGOPTSSYNTAX" = "true" ]; then + _launch_qemu \ + -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk +else + _launch_qemu \ + -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk +fi src=$QEMU_HANDLE -_launch_qemu \ - -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk \ - -incoming "unix:${MIG_SOCKET}" +if [ "$IMGOPTSSYNTAX" = "true" ]; then + _launch_qemu \ + -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk \ + -incoming "unix:${MIG_SOCKET}" +else + _launch_qemu \ + -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk \ + -incoming "unix:${MIG_SOCKET}" +fi dest=$QEMU_HANDLE echo
tests/qemu-iotests/common.qemu +7 -2
@@ -153,14 +153,19 @@ function _launch_qemu() mkfifo "${fifo_out}" mkfifo "${fifo_in}" + object_options= + if [ -n "$IMGKEYSECRET" ]; then + object_options="--object secret,id=keysec0,data=$IMGKEYSECRET" + fi + if [ -z "$keep_stderr" ]; then QEMU_NEED_PID='y'\ - ${QEMU} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ + ${QEMU} ${object_options} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ 2>&1 \ <"${fifo_in}" & elif [ "$keep_stderr" = "y" ]; then QEMU_NEED_PID='y'\ - ${QEMU} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ + ${QEMU} ${object_options} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ <"${fifo_in}" & else exit 1
Signature · 1 line
2.9.3
PATCH v6 4/5 iotests: add more LUKS hash combination tests
In reply to Daniel P. BerrangeAdd tests for sha224, sha512, sha384 and ripemd160 hash algorithms.
--- tests/qemu-iotests/149 | 10 +- tests/qemu-iotests/149.out | 482 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 484 insertions(+), 8 deletions(-)
tests/qemu-iotests/149 +4 -6
@@ -457,8 +457,12 @@ configs = [ # LUKS default but diff hash + LUKSConfig("aes-256-xts-plain64-sha224", + "aes", 256, "xts", "plain64", None, "sha224"), LUKSConfig("aes-256-xts-plain64-sha256", "aes", 256, "xts", "plain64", None, "sha256"), + LUKSConfig("aes-256-xts-plain64-sha384", + "aes", 256, "xts", "plain64", None, "sha384"), LUKSConfig("aes-256-xts-plain64-sha512", "aes", 256, "xts", "plain64", None, "sha512"), LUKSConfig("aes-256-xts-plain64-ripemd160",
@@ -504,12 +508,6 @@ blacklist = [ # GCrypt doesn't support Twofish with 192 bit key "twofish-192-xts-plain64-sha1", - - # We don't have sha512 hash wired up yet - "aes-256-xts-plain64-sha512", - - # We don't have ripemd160 hash wired up yet - "aes-256-xts-plain64-ripemd160", ] whitelist = []
tests/qemu-iotests/149.out +480 -2
494 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v6 3/5 iotests: reduce PBKDF iterations when testing LUKS
In reply to Daniel P. BerrangeBy default the PBKDF algorithm used with LUKS is tuned based on the number of iterations to produce 1 second of running time. This makes running the I/O test with the LUKS format orders of magnitude slower than with qcow2/raw formats.
When creating LUKS images, set the iteration time to a 10ms to reduce the time overhead for LUKS, since security does not matter in I/O tests.
Previously a full 'check -luks' would take
$ time ./check -luks Passed all 22 tests
real 23m9.988s user 21m46.223s sys 0m22.841s
Now it takes
$ time ./check -luks Passed all 22 tests
real 4m39.235s user 3m29.590s sys 0m24.234s
Still slow compared to qcow2/raw, but much improved none the less.
--- tests/qemu-iotests/149 | 3 + tests/qemu-iotests/149.out | 118 +++++++++++++++++++-------------------- tests/qemu-iotests/common.filter | 3 +- tests/qemu-iotests/common.rc | 3 + 4 files changed, 67 insertions(+), 60 deletions(-)
tests/qemu-iotests/149 +3 -0
@@ -136,6 +136,7 @@ def cryptsetup_add_password(config, slot): args = ["luksAddKey", config.image_path(), "--key-slot", slot, "--key-file", "-", + "--iter-time", "10", pwfile] cryptsetup(args, password)
@@ -164,6 +165,7 @@ def cryptsetup_format(config): args.extend(["--hash", config.hash]) args.extend(["--key-slot", slot]) args.extend(["--key-file", "-"]) + args.extend(["--iter-time", "10"]) args.append(config.image_path()) cryptsetup(args, password)
@@ -230,6 +232,7 @@ def qemu_img_create(config, size_mb): opts = [ "key-secret=sec0", + "iter-time=10", "cipher-alg=%s-%d" % (config.cipher, config.keylen), "cipher-mode=%s" % config.mode, "ivgen-alg=%s" % config.ivgen,
tests/qemu-iotests/149.out +59 -59
335 lines not on this page · raw message
tests/qemu-iotests/common.filter +2 -1
@@ -126,7 +126,8 @@ _filter_img_create() -e "s# block_state_zero=\\(on\\|off\\)##g" \ -e "s# log_size=[0-9]\\+##g" \ -e "s# refcount_bits=[0-9]\\+##g" \ - -e "s# key-secret=[a-zA-Z0-9]\\+##g" + -e "s# key-secret=[a-zA-Z0-9]\\+##g" \ + -e "s# iter-time=[0-9]\\+##g" } _filter_img_info()
tests/qemu-iotests/common.rc +3 -0
@@ -107,6 +107,9 @@ _set_default_imgopts() if [ "$IMGFMT" == "qcow2" ] && ! (echo "$IMGOPTS" | grep "compat=" > /dev/null); then IMGOPTS=$(_optstr_add "$IMGOPTS" "compat=1.1") fi + if [ "$IMGFMT" == "luks" ] && ! (echo "$IMGOPTS" | grep "iter-time=" > /dev/null); then + IMGOPTS=$(_optstr_add "$IMGOPTS" "iter-time=10") + fi } _use_sample_img()
Signature · 1 line
2.9.3
PATCH v6 5/5 iotests: chown LUKS device before qemu-io launches
In reply to Daniel P. BerrangeOn some distros, whenever you close a block device file descriptor there is a udev rule that resets the file permissions. This can race with the test script when we run qemu-io multiple times against the same block device. Occasionally the second qemu-io invocation will find udev has reset the permissions causing failure.
--- tests/qemu-iotests/149 | 12 +- tests/qemu-iotests/149.out | 344 ++++++++++++++++++++++----------------------- 2 files changed, 177 insertions(+), 179 deletions(-)
tests/qemu-iotests/149 +5 -7
@@ -186,7 +186,7 @@ def chown(config): msg = proc.communicate()[0] if proc.returncode != 0: - raise Exception("Cannot change owner on %s" % path) + raise Exception(msg) def cryptsetup_open(config):
@@ -271,6 +271,8 @@ def qemu_io_image_args(config, dev=False): def qemu_io_write_pattern(config, pattern, offset_mb, size_mb, dev=False): """Write a pattern of data to a LUKS image or device""" + if dev: + chown(config) args = ["-c", "write -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)] args.extend(qemu_io_image_args(config, dev)) iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
@@ -281,6 +283,8 @@ def qemu_io_write_pattern(config, pattern, offset_mb, size_mb, dev=False): def qemu_io_read_pattern(config, pattern, offset_mb, size_mb, dev=False): """Read a pattern of data to a LUKS image or device""" + if dev: + chown(config) args = ["-c", "read -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)] args.extend(qemu_io_image_args(config, dev)) iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
@@ -331,9 +335,6 @@ def test_once(config, qemu_img=False): cryptsetup_open(config) try: - iotests.log("# Set dev owner") - chown(config) - iotests.log("# Write test pattern 0xa7") qemu_io_write_pattern(config, 0xa7, lowOffsetMB, 10, dev=True) iotests.log("# Write test pattern 0x13")
@@ -365,9 +366,6 @@ def test_once(config, qemu_img=False): cryptsetup_open(config) try: - iotests.log("# Set dev owner") - chown(config) - iotests.log("# Read test pattern 0x91") qemu_io_read_pattern(config, 0x91, lowOffsetMB, 10, dev=True) iotests.log("# Read test pattern 0x5e")
tests/qemu-iotests/149.out +172 -172
1,376 lines not on this page · raw message
Signature · 1 line
2.9.3
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PATCH v6 0/5] Improve I/O tests coverage of LUKS driver
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Traceback (most recent call last):
File "./patchew-cli", line 430, in test_one
git_clone_repo(clone, r["repo"], r["head"], logf)
File "./patchew-cli", line 48, in git_clone_repo
stdout=logf, stderr=logf)
File "/usr/lib64/python3.5/subprocess.py", line 266, in check_call
retcode = call(*popenargs, **kwargs)
File "/usr/lib64/python3.5/subprocess.py", line 249, in call
return p.wait(timeout=timeout)
File "/usr/lib64/python3.5/subprocess.py", line 1389, in wait
(pid, sts) = self._try_wait(0) File "/usr/lib64/python3.5/subprocess.py", line 1339, in _try_wait
(pid, sts) = os.waitpid(self.pid, wait_flags)
KeyboardInterrupt
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Quoted 12 lines · On Tue, 06/27 07:43, [email protected] wrote:
Updating
3c8cf5a9c21ff8782164d1def7f44bd888713384
Traceback (most recent call last):
File "./patchew-cli", line 430, intest_onegit_clone_repo(clone, r["repo"], r["head"], logf) File "./patchew-cli", line 48, in git_clone_repo stdout=logf, stderr=logf) File "/usr/lib64/python3.5/subprocess.py", line 266, in check_call retcode = call(*popenargs, **kwargs) File "/usr/lib64/python3.5/subprocess.py", line 249, in call return p.wait(timeout=timeout) File "/usr/lib64/python3.5/subprocess.py", line 1389, in wait (pid, sts) = self._try_wait(0)
Quoted 3 lines
File "
/usr/lib64/python3.5/subprocess.py", line 1339, in_try_wait
(pid, sts) =os.waitpid(self.pid, wait_flags)
KeyboardInterrupt
My mistake, sorry for the noise.
Fam
Max Reitz
AppliedQuoted 9 lines · Daniel P. Berrange
The main goal of this series is to get the I/O tests passing 100% with LUKS when run with './check -luks'. It also adds a few more combinations to the LUKS/dmcrypt interoperability test.
To make LUKS testing not quite as slow, we drop the PBKDF iteration count down to a very small value. This doesn't remove all overhead, as formatting the volume will always measure PBKDF timing over a 1 second interval.
Thanks, applied to my block branch:
https://github.com/XanClic/qemu/commits/block
Max