Skip to contentSkip to conversation

Improve I/O tests coverage of LUKS

PATCH Superseded Daniel P. Berrange 3 participants 15 messages Sep 19, 2016 – Oct 31, 2016

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover Improve I/O tests coverage of LUKS

The main goal of this series is to get the I/O tests passing 100% with LUKS when run with './check -luks'.

In testing this I noticed that test timings are cached across runs with different block backends which is very misleading.

It 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.

Finally I've been trying to get I/O tests working under travis and hitting a tonne of non-deterministic failures, even with qcow2 format. I've put one easy fix at the end, but there are more needed. If anyone fancies testing travis more, the config change I was experimenting with is

.travis.yml +12 -1
index f30b10e..7b5fe92 100644
@@ -33,6 +33,7 @@ addons:
       - libvte-2.90-dev
       - sparse
       - uuid-dev
+      - bc
 
 # The channel name "irc.oftc.net#qemu" is encrypted against qemu/qemu
 # to prevent IRC notifications from forks. This was created using:
@@ -64,7 +65,7 @@ before_install:
 before_script:
   - ./configure ${CONFIG}
 script:
-  - make -j3 && ${TEST_CMD}
+  - make -j3 && eval ${TEST_CMD}
 matrix:
   include:
     # gprof/gcov are GCC features
@@ -86,6 +87,16 @@ matrix:
     - env: CONFIG="--with-coroutine=gthread"
            TEST_CMD=""
       compiler: gcc
+    - env: CONFIG="--target-list=x86_64-softmmu"
+           TEST_CMD="cd tests/qemu-iotests && ./check -luks"
+      compiler: gcc
+      sudo: required
+    - env: CONFIG="--target-list=x86_64-softmmu"
+           TEST_CMD="cd tests/qemu-iotests && ./check -raw"
+      compiler: gcc
+    - env: CONFIG="--target-list=x86_64-softmmu"
+           TEST_CMD="cd tests/qemu-iotests && ./check -qcow2"
+      compiler: gcc
     - env: CONFIG=""
       os: osx
       compiler: clang

All three tests - luks, raw and qcow2 - will randomly fail very often when run on public travis infra IME :-(

Daniel P. Berrange (6):
iotests: throw away test timings if args change
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
iotests: use _filter_qemu with test 140

 tests/qemu-iotests/033           |   16 +-
 tests/qemu-iotests/120           |   25 +-
 tests/qemu-iotests/140           |   17 +-
 tests/qemu-iotests/145           |   18 +-
 tests/qemu-iotests/149           |   26 +-
 tests/qemu-iotests/149.out       | 1002 ++++++++++++++++++++++++++++----------
 tests/qemu-iotests/157           |   17 +-
 tests/qemu-iotests/157.out       |   16 +-
 tests/qemu-iotests/check         |   21 +-
 tests/qemu-iotests/common.filter |    3 +-
 tests/qemu-iotests/common.rc     |    3 +
 11 files changed, 865 insertions(+), 299 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/6 iotests: throw away test timings if args change

The 'check' program records timings for each test that is run. These timings are only valid, however, for a particular format/protocol combination. So if frequently running 'check' with a variety of different formats or protocols, the times printed can be very misleading.

Record the protocol/format in the check.time file and throw it away if it doesn't mach the current run args.

---
 tests/qemu-iotests/check | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
tests/qemu-iotests/check +19 -2
index 4cba215..1a9bbb7 100755
@@ -142,6 +142,11 @@ _timestamp()
     echo -n " [$now]"
 }
 
+_timestamp_args()
+{
+    echo "# ARGS: protocol=$IMGPROTO, format=$IMGFMT"
+}
+
 _wrapup()
 {
     # for hangcheck ...
@@ -158,13 +163,14 @@ _wrapup()
         if [ -f check.time -a -f $tmp.time ]
         then
             cat check.time $tmp.time \
-            | $AWK_PROG '
+            | grep -v '# ' | $AWK_PROG '
         { t[$1] = $2 }
 END        { if (NR > 0) {
             for (i in t) print i " " t[i]
           }
         }' \
             | sort -n >$tmp.out
+            _timestamp_args >> $tmp.out
             mv $tmp.out check.time
         fi
 
@@ -223,7 +229,18 @@ echo "preamble" > "${TEST_DIR}"/check.sts
 # don't leave old full output behind on a clean run
 rm -f check.full
 
-[ -f check.time ] || touch check.time
+# Check if previously recorded times were for the same
+# image format/protocol, otherwise discard them
+if test -f check.time
+then
+   OLDARGS=`grep ARGS check.time`
+   NEWARGS=`_timestamp_args`
+   if test "x$OLDARGS" != "x$NEWARGS"
+   then
+       rm -f check.time
+   fi
+fi
+touch check.time
 
 FULL_IMGFMT_DETAILS=`_full_imgfmt_details`
 FULL_IMGPROTO_DETAILS=`_full_imgproto_details`
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/6] iotests: throw away test timings if args change

Quoted 6 lines · Daniel P. Berrange

The 'check' program records timings for each test that is run. These timings are only valid, however, for a particular format/protocol combination. So if frequently running 'check' with a variety of different formats or protocols, the times printed can be very misleading.

Quoted 7 lines

Record the protocol/format in the check.time file and throw it away if it doesn't mach the current run args.

---
 tests/qemu-iotests/check | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

Rather than completely throwing things away, would it be worth updating the check.time file format to track multiple entries? For every distinct args seen, track a timing for that combination of args, then when starting a test, if a line in the file contains the current args, report that old time; if not, then append a line with the new args. The file grows according to how many distinct args combinations you use, and it's probably easier to make 'a b' and 'b a' report as different timings even if they have the same effect and could share a timing. We'd also want an operation to clean out timings without running tests, particularly if timings can otherwise grow huge due to every possible args combination.

What do you think?

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#3 lore raw

Re: [Qemu-devel] [PATCH 1/6] iotests: throw away test timings if args change

Quoted 26 lines · Eric Blake
Quoted 6 lines · Daniel P. Berrange

The 'check' program records timings for each test that is run. These timings are only valid, however, for a particular format/protocol combination. So if frequently running 'check' with a variety of different formats or protocols, the times printed can be very misleading.

Quoted 7 lines

Record the protocol/format in the check.time file and throw it away if it doesn't mach the current run args.

---
 tests/qemu-iotests/check | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

Rather than completely throwing things away, would it be worth updating the check.time file format to track multiple entries? For every distinct args seen, track a timing for that combination of args, then when starting a test, if a line in the file contains the current args, report that old time; if not, then append a line with the new args. The file grows according to how many distinct args combinations you use, and it's probably easier to make 'a b' and 'b a' report as different timings even if they have the same effect and could share a timing. We'd also want an operation to clean out timings without running tests, particularly if timings can otherwise grow huge due to every possible args combination.

Quoted 1 line

What do you think?

I was afraid someone would suggest a more complex scheme like that :-)

I guess we could keep things simple by not inventing a new format, but instead of using 'check.time', use 'check.time.$FORMAT-$PROTOCOL' eg 'check.time.qcow2-file'

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#4 lore raw

Re: [Qemu-devel] [PATCH 1/6] iotests: throw away test timings if args change

Quoted 11 lines · Daniel P. Berrange
Quoted 11 lines

Rather than completely throwing things away, would it be worth updating the check.time file format to track multiple entries? For every distinct args seen, track a timing for that combination of args, then when starting a test, if a line in the file contains the current args, report that old time; if not, then append a line with the new args. The file grows according to how many distinct args combinations you use, and it's probably easier to make 'a b' and 'b a' report as different timings even if they have the same effect and could share a timing. We'd also want an operation to clean out timings without running tests, particularly if timings can otherwise grow huge due to every possible args combination.

Quoted 7 lines
Quoted 1 line

What do you think?

I was afraid someone would suggest a more complex scheme like that :-)

I guess we could keep things simple by not inventing a new format, but instead of using 'check.time', use 'check.time.$FORMAT-$PROTOCOL' eg 'check.time.qcow2-file'

Seems more palatable. Lots of files rather than lots of lines in a single file; searching is now fast (if you can come up with the right file name, the OS does the searching for you rather than us having to figure out which (if any) portion of a large file applies). We may still want a command for easily cleaning everything, and if we do switch to new file names, we'll still want to clean up the old files.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#5 lore raw

Re: [Qemu-devel] [PATCH 1/6] iotests: throw away test timings if args change

Quoted 20 lines · Eric Blake
Quoted 11 lines · Daniel P. Berrange
Quoted 11 lines

Rather than completely throwing things away, would it be worth updating the check.time file format to track multiple entries? For every distinct args seen, track a timing for that combination of args, then when starting a test, if a line in the file contains the current args, report that old time; if not, then append a line with the new args. The file grows according to how many distinct args combinations you use, and it's probably easier to make 'a b' and 'b a' report as different timings even if they have the same effect and could share a timing. We'd also want an operation to clean out timings without running tests, particularly if timings can otherwise grow huge due to every possible args combination.

Quoted 7 lines
Quoted 1 line

What do you think?

I was afraid someone would suggest a more complex scheme like that :-)

I guess we could keep things simple by not inventing a new format, but instead of using 'check.time', use 'check.time.$FORMAT-$PROTOCOL' eg 'check.time.qcow2-file'

Quoted 6 lines

Seems more palatable. Lots of files rather than lots of lines in a single file; searching is now fast (if you can come up with the right file name, the OS does the searching for you rather than us having to figure out which (if any) portion of a large file applies). We may still want a command for easily cleaning everything, and if we do switch to new file names, we'll still want to clean up the old files.

Isn't that command called 'git clean -f' - if we remove 'check.time' from the gitignore file, it'll be deleted by a git clean, without needing to ass the -i flag. I don't think we really need to reinvent a special way to clean just these timing files, particularly since they are not large.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#6 lore raw

Re: [Qemu-devel] [PATCH 1/6] iotests: throw away test timings if args change

Quoted 11 lines · Daniel P. Berrange
Quoted 10 lines
Quoted 3 lines

I guess we could keep things simple by not inventing a new format, but instead of using 'check.time', use 'check.time.$FORMAT-$PROTOCOL' eg 'check.time.qcow2-file'

Seems more palatable. Lots of files rather than lots of lines in a single file; searching is now fast (if you can come up with the right file name, the OS does the searching for you rather than us having to figure out which (if any) portion of a large file applies). We may still want a command for easily cleaning everything, and if we do switch to new file names, we'll still want to clean up the old files.

Quoted 5 lines

Isn't that command called 'git clean -f' - if we remove 'check.time' from the gitignore file, it'll be deleted by a git clean, without needing to ass the -i flag. I don't think we really need to reinvent a special way to clean just these timing files, particularly since they are not large.

I'd still rather have the gitignore file ignore anything that we don't want to check into the tree (I'm a big fan of 'git add -a .', and hate it when non-ignored generated files interfere with that; yes I know I can munge .git/info/exclude locally, but it feels cleaner when generated files are ignored at the project level).

But yes, relying on git to do the cleanup is fine from my point of view.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#7 lore raw

Re: [Qemu-devel] [PATCH 1/6] iotests: throw away test timings if args change

Quoted 18 lines · Eric Blake
Quoted 11 lines · Daniel P. Berrange
Quoted 10 lines
Quoted 3 lines

I guess we could keep things simple by not inventing a new format, but instead of using 'check.time', use 'check.time.$FORMAT-$PROTOCOL' eg 'check.time.qcow2-file'

Seems more palatable. Lots of files rather than lots of lines in a single file; searching is now fast (if you can come up with the right file name, the OS does the searching for you rather than us having to figure out which (if any) portion of a large file applies). We may still want a command for easily cleaning everything, and if we do switch to new file names, we'll still want to clean up the old files.

Quoted 5 lines

Isn't that command called 'git clean -f' - if we remove 'check.time' from the gitignore file, it'll be deleted by a git clean, without needing to ass the -i flag. I don't think we really need to reinvent a special way to clean just these timing files, particularly since they are not large.

Quoted 7 lines

I'd still rather have the gitignore file ignore anything that we don't want to check into the tree (I'm a big fan of 'git add -a .', and hate it when non-ignored generated files interfere with that; yes I know I can munge .git/info/exclude locally, but it feels cleaner when generated files are ignored at the project level).

But yes, relying on git to do the cleanup is fine from my point of view.

NB, I'd still suggest ignoring check.time-$FORMAT-BACKEND files since those are current. I was just refering to removal of the legacy check.time file so next git cleanup kills the obsolete file

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#8 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH 1/6] iotests: throw away test timings if args change

Am 20.09.2016 um 16:39 hat Daniel P. Berrange geschrieben:

Quoted 25 lines · Eric Blake
Quoted 24 lines · Daniel P. Berrange
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines

I guess we could keep things simple by not inventing a new format, but instead of using 'check.time', use 'check.time.$FORMAT-$PROTOCOL' eg 'check.time.qcow2-file'

Seems more palatable. Lots of files rather than lots of lines in a single file; searching is now fast (if you can come up with the right file name, the OS does the searching for you rather than us having to figure out which (if any) portion of a large file applies). We may still want a command for easily cleaning everything, and if we do switch to new file names, we'll still want to clean up the old files.

Quoted 5 lines

Isn't that command called 'git clean -f' - if we remove 'check.time' from the gitignore file, it'll be deleted by a git clean, without needing to ass the -i flag. I don't think we really need to reinvent a special way to clean just these timing files, particularly since they are not large.

I'd still rather have the gitignore file ignore anything that we don't want to check into the tree (I'm a big fan of 'git add -a .', and hate it when non-ignored generated files interfere with that; yes I know I can munge .git/info/exclude locally, but it feels cleaner when generated files are ignored at the project level).

Quoted 5 lines
Quoted 1 line

But yes, relying on git to do the cleanup is fine from my point of view.

NB, I'd still suggest ignoring check.time-$FORMAT-BACKEND files since those are current. I was just refering to removal of the legacy check.time file so next git cleanup kills the obsolete file

Was there a v2 of this series that I missed or was it just forgotten?

Kevin

#9 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH 1/6] iotests: throw away test timings if args change

Quoted 26 lines · Kevin Wolf

Am 20.09.2016 um 16:39 hat Daniel P. Berrange geschrieben:

Quoted 25 lines · Eric Blake
Quoted 24 lines · Daniel P. Berrange
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines

I guess we could keep things simple by not inventing a new format, but instead of using 'check.time', use 'check.time.$FORMAT-$PROTOCOL' eg 'check.time.qcow2-file'

Seems more palatable. Lots of files rather than lots of lines in a single file; searching is now fast (if you can come up with the right file name, the OS does the searching for you rather than us having to figure out which (if any) portion of a large file applies). We may still want a command for easily cleaning everything, and if we do switch to new file names, we'll still want to clean up the old files.

Quoted 5 lines

Isn't that command called 'git clean -f' - if we remove 'check.time' from the gitignore file, it'll be deleted by a git clean, without needing to ass the -i flag. I don't think we really need to reinvent a special way to clean just these timing files, particularly since they are not large.

I'd still rather have the gitignore file ignore anything that we don't want to check into the tree (I'm a big fan of 'git add -a .', and hate it when non-ignored generated files interfere with that; yes I know I can munge .git/info/exclude locally, but it feels cleaner when generated files are ignored at the project level).

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

But yes, relying on git to do the cleanup is fine from my point of view.

NB, I'd still suggest ignoring check.time-$FORMAT-BACKEND files since those are current. I was just refering to removal of the legacy check.time file so next git cleanup kills the obsolete file

Was there a v2 of this series that I missed or was it just forgotten?

I never got around to sending a v2

Regards,
Daniel

Signature · 3 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|
#10 lore raw

PATCH 2/6 iotests: fix remainining tests to work with LUKS

In reply to Daniel P. Berrange

The tests 033, 120, 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.

---
 tests/qemu-iotests/033     | 16 ++++++++++++----
 tests/qemu-iotests/120     | 25 ++++++++++++++++++++++---
 tests/qemu-iotests/140     | 15 ++++++++++++++-
 tests/qemu-iotests/145     | 18 +++++++++++++++++-
 tests/qemu-iotests/157     | 17 ++++++++++++++---
 tests/qemu-iotests/157.out | 16 ++++++++--------
 6 files changed, 87 insertions(+), 20 deletions(-)
tests/qemu-iotests/033 +12 -4
index 16edcf2..b690b0e 100755
@@ -50,14 +50,22 @@ do_test()
 	local align=$1
 	local iocmd=$2
 	local img=$3
+	if test "$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
-for align in 512 4k; do
+    for align in 512 4k; do
 	echo
 	echo "== preparing image =="
 	do_test $align "write -P 0xa 0x200 0x400" "$TEST_IMG" | _filter_qemu_io
@@ -91,7 +99,7 @@ for align in 512 4k; do
 	do_test $align "read -P 0xb 0x400 0xc00" "$TEST_IMG" | _filter_qemu_io
 
 	echo
-done
+    done
 done
 
 # success, all done
tests/qemu-iotests/120 +22 -3
index 4f88a67..5f80517 100755
@@ -44,17 +44,36 @@ _supported_os Linux
 
 _make_test_img 64M
 
+if test "$IMGOPTSSYNTAX" = "true"
+then
+    SYSEMU_DRIVE_ARG=id=drv,if=none,$TEST_IMG
+    SYSEMU_EXTRA_ARGS=""
+    IO_DRIVE_ARG="$TEST_IMG"
+    IO_EXTRA_ARGS="--image-opts"
+    if [ -n "$IMGKEYSECRET" ]; then
+	SECRET_ARG="secret,id=keysec0,data=$IMGKEYSECRET"
+	SYSEMU_EXTRA_ARGS="$SYSEMU_EXTRA_ARGS -object $SECRET_ARG"
+	IO_EXTRA_ARGS="$IO_EXTRA_ARGS --object $SECRET_ARG"
+    fi
+else
+    SYSEMU_DRIVE_ARG=id=drv,if=none,file="$TEST_IMG",driver=raw,file.driver=$IMGFMT
+    SYSEMU_EXTRA_ARGS=""
+    IO_DRIVE_ARG="json:{'driver': 'raw', 'file': {'driver': '$IMGFMT', 'file': {'filename': '$TEST_IMG'}}}"
+    IO_EXTRA_ARGS=""
+fi
+
+
 echo "{'execute': 'qmp_capabilities'}
       {'execute': 'human-monitor-command',
        'arguments': {'command-line': 'qemu-io drv \"write -P 42 0 64k\"'}}
       {'execute': 'quit'}" \
-    | $QEMU -qmp stdio -nographic -nodefaults \
-            -drive id=drv,if=none,file="$TEST_IMG",driver=raw,file.driver=$IMGFMT \
+    | $QEMU -qmp stdio -nographic -nodefaults $SYSEMU_EXTRA_ARGS \
+            -drive $SYSEMU_DRIVE_ARG \
     | _filter_qmp | _filter_qemu_io
 $QEMU_IO -c 'read -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io
 
 $QEMU_IO_PROG -c 'read -P 42 0 64k' \
-    "json:{'driver': 'raw', 'file': {'driver': '$IMGFMT', 'file': {'filename': '$TEST_IMG'}}}" \
+    $IO_EXTRA_ARGS "$IO_DRIVE_ARG" \
     | _filter_qemu_io
 
 # success, all done
tests/qemu-iotests/140 +14 -1
index 49f9df4..afaa418 100755
@@ -51,8 +51,21 @@ _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
+    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,media=cdrom,id=drv,file="$TEST_IMG",driver=raw,file.driver=$IMGFMT
+    SYSEMU_EXTRA_ARGS=""
+fi
+
 keep_stderr=y \
-_launch_qemu -drive if=none,media=cdrom,id=drv,file="$TEST_IMG",format=$IMGFMT \
+_launch_qemu $SYSEMU_EXTRA_ARGS -drive $SYSEMU_DRIVE_ARG \
     2> >(_filter_nbd)
 
 _send_qemu_cmd $QEMU_HANDLE \
tests/qemu-iotests/145 +17 -1
index 1eca0e8..ab54972 100755
@@ -43,7 +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
+
+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=raw,file.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
 
 # success, all done
 echo "*** done"
tests/qemu-iotests/157 +14 -3
index 8d939cb..9ba1720 100755
@@ -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=raw,file.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
index 77a9c03..fdc807f 100644
@@ -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
Signature · 1 line
2.7.4
#11 lore raw

PATCH 3/6 iotests: reduce PBKDF iterations when testing LUKS

In reply to Daniel P. Berrange

By 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.

Previsouly 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
index 8407251..f62e618 100755
@@ -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
index 3ab6e4d..b1c871d 100644
@@ -105,7 +105,8 @@ _filter_img_create()
         -e "s# log_size=[0-9]\\+##g" \
         -e "s/archipelago:a/TEST_DIR\//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
index 306b00c..42b1f58 100644
@@ -108,6 +108,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.7.4
#12 lore raw

PATCH 4/6 iotests: add more LUKS hash combination tests

In reply to Daniel P. Berrange

Add 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
index f62e618..5faf585 100755
@@ -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.7.4
#13 lore raw

PATCH 5/6 iotests: chown LUKS device before qemu-io launches

In reply to Daniel P. Berrange

On 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. Occassionally the second qemu-io invokation will find udev has reset the permissions causing failure.

---
 tests/qemu-iotests/149     |  13 +-
 tests/qemu-iotests/149.out | 344 ++++++++++++++++++++++-----------------------
 2 files changed, 178 insertions(+), 179 deletions(-)
tests/qemu-iotests/149 +6 -7
index 5faf585..bc628ce 100755
@@ -23,6 +23,7 @@
 import subprocess
 import os
 import os.path
+import time
 
 import base64
 
@@ -186,7 +187,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 +272,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 +284,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 +336,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 +367,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.7.4
#14 lore raw

PATCH 6/6 iotests: use _filter_qemu with test 140

In reply to Daniel P. Berrange

When run on a loaded host, QEMU may print

main-loop: WARNING: I/O thread spun for 10 iterations

so we must take care to filter that message.

---
 tests/qemu-iotests/140 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/140 +1 -1
index afaa418..5ee98c5 100755
@@ -66,7 +66,7 @@ fi
 
 keep_stderr=y \
 _launch_qemu $SYSEMU_EXTRA_ARGS -drive $SYSEMU_DRIVE_ARG \
-    2> >(_filter_nbd)
+    2> >(_filter_nbd| _filter_qemu)
 
 _send_qemu_cmd $QEMU_HANDLE \
     "{ 'execute': 'qmp_capabilities' }" \
Signature · 1 line
2.7.4