qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 20170626123510.20134-3-berrange@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>

authored by

Daniel P. Berrange and committed by
Max Reitz
13a1d4a7 2c6f6006

+82 -24
+10 -2
tests/qemu-iotests/033
··· 50 50 local align=$1 51 51 local iocmd=$2 52 52 local img=$3 53 + if [ "$IMGOPTSSYNTAX" = "true" ] 54 + then 55 + IO_OPEN_ARG="$img" 56 + IO_EXTRA_ARGS="--image-opts" 57 + else 58 + IO_OPEN_ARG="-o driver=$IMGFMT,file.align=$align blkdebug::$img" 59 + IO_EXTRA_ARGS="" 60 + fi 53 61 { 54 - echo "open -o driver=$IMGFMT,file.align=$align blkdebug::$img" 62 + echo "open $IO_OPEN_ARG" 55 63 echo $iocmd 56 - } | $QEMU_IO 64 + } | $QEMU_IO $IO_EXTRA_ARGS 57 65 } 58 66 59 67 for write_zero_cmd in "write -z" "aio_write -z"; do
+1
tests/qemu-iotests/120
··· 41 41 _supported_fmt generic 42 42 _supported_proto file 43 43 _supported_os Linux 44 + _unsupported_fmt luks 44 45 45 46 _make_test_img 64M 46 47
+8 -1
tests/qemu-iotests/140
··· 52 52 53 53 $QEMU_IO -c 'write -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io 54 54 55 + if test "$IMGOPTSSYNTAX" = "true" 56 + then 57 + SYSEMU_DRIVE_ARG=if=none,media=cdrom,id=drv,"$TEST_IMG" 58 + else 59 + SYSEMU_DRIVE_ARG=if=none,media=cdrom,id=drv,file="$TEST_IMG",driver=$IMGFMT 60 + fi 61 + 55 62 keep_stderr=y \ 56 - _launch_qemu -drive if=none,media=cdrom,id=drv,file="$TEST_IMG",format=$IMGFMT \ 63 + _launch_qemu -drive $SYSEMU_DRIVE_ARG \ 57 64 2> >(_filter_nbd) 58 65 59 66 _send_qemu_cmd $QEMU_HANDLE \
+17 -2
tests/qemu-iotests/145
··· 43 43 _supported_os Linux 44 44 45 45 _make_test_img 1M 46 - echo quit | $QEMU -nographic -hda "$TEST_IMG" -incoming 'exec:true' -snapshot -serial none -monitor stdio | 47 - _filter_qemu | _filter_hmp 46 + 47 + if test "$IMGOPTSSYNTAX" = "true" 48 + then 49 + SYSEMU_DRIVE_ARG=if=none,$TEST_IMG 50 + SYSEMU_EXTRA_ARGS="" 51 + if [ -n "$IMGKEYSECRET" ]; then 52 + SECRET_ARG="secret,id=keysec0,data=$IMGKEYSECRET" 53 + SYSEMU_EXTRA_ARGS="-object $SECRET_ARG" 54 + fi 55 + else 56 + SYSEMU_DRIVE_ARG=if=none,file="$TEST_IMG",driver=$IMGFMT 57 + SYSEMU_EXTRA_ARGS="" 58 + fi 59 + 60 + echo quit | $QEMU -nographic $SYSEMU_EXTRA_ARGS -drive $SYSEMU_DRIVE_ARG \ 61 + -incoming 'exec:true' -snapshot -serial none -monitor stdio \ 62 + | _filter_qemu | _filter_hmp 48 63 49 64 # success, all done 50 65 echo "*** done"
+14 -3
tests/qemu-iotests/157
··· 43 43 44 44 function do_run_qemu() 45 45 { 46 - echo Testing: "$@" 47 46 ( 48 47 if ! test -t 0; then 49 48 while read cmd; do ··· 63 62 64 63 65 64 size=128M 66 - drive="if=none,file=$TEST_IMG,driver=$IMGFMT" 65 + if test "$IMGOPTSSYNTAX" = "true" 66 + then 67 + SYSEMU_DRIVE_ARG=if=none,$TEST_IMG 68 + SYSEMU_EXTRA_ARGS="" 69 + if [ -n "$IMGKEYSECRET" ]; then 70 + SECRET_ARG="secret,id=keysec0,data=$IMGKEYSECRET" 71 + SYSEMU_EXTRA_ARGS="-object $SECRET_ARG" 72 + fi 73 + else 74 + SYSEMU_DRIVE_ARG=if=none,file="$TEST_IMG",driver=$IMGFMT 75 + SYSEMU_EXTRA_ARGS="" 76 + fi 67 77 68 78 _make_test_img $size 69 79 ··· 76 86 77 87 for cache in "writeback" "writethrough"; do 78 88 for wce in "" ",write-cache=auto" ",write-cache=on" ",write-cache=off"; do 89 + echo "Testing: cache='$cache' wce='$wce'" 79 90 echo "info block" \ 80 - | run_qemu -drive "$drive,cache=$cache" \ 91 + | run_qemu $SYSEMU_EXTRA_ARGS -drive "$SYSEMU_DRIVE_ARG,cache=$cache" \ 81 92 -device "virtio-blk,drive=none0$wce" \ 82 93 | grep -e "Testing" -e "Cache mode" 83 94 done
+8 -8
tests/qemu-iotests/157.out
··· 3 3 4 4 === Setting WCE with qdev and with manually created BB === 5 5 6 - Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writeback -device virtio-blk,drive=none0 6 + Testing: cache='writeback' wce='' 7 7 Cache mode: writeback 8 - Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writeback -device virtio-blk,drive=none0,write-cache=auto 8 + Testing: cache='writeback' wce=',write-cache=auto' 9 9 Cache mode: writeback 10 - Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writeback -device virtio-blk,drive=none0,write-cache=on 10 + Testing: cache='writeback' wce=',write-cache=on' 11 11 Cache mode: writeback 12 - Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writeback -device virtio-blk,drive=none0,write-cache=off 12 + Testing: cache='writeback' wce=',write-cache=off' 13 13 Cache mode: writethrough 14 - Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writethrough -device virtio-blk,drive=none0 14 + Testing: cache='writethrough' wce='' 15 15 Cache mode: writethrough 16 - Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writethrough -device virtio-blk,drive=none0,write-cache=auto 16 + Testing: cache='writethrough' wce=',write-cache=auto' 17 17 Cache mode: writethrough 18 - Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writethrough -device virtio-blk,drive=none0,write-cache=on 18 + Testing: cache='writethrough' wce=',write-cache=on' 19 19 Cache mode: writeback 20 - Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,driver=IMGFMT,cache=writethrough -device virtio-blk,drive=none0,write-cache=off 20 + Testing: cache='writethrough' wce=',write-cache=off' 21 21 Cache mode: writethrough 22 22 *** done
+1 -1
tests/qemu-iotests/174
··· 41 41 42 42 43 43 size=256K 44 - IMGFMT=raw IMGOPTS= _make_test_img $size | _filter_imgfmt 44 + IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt 45 45 46 46 echo 47 47 echo "== reading wrong format should fail =="
+16 -5
tests/qemu-iotests/181
··· 57 57 58 58 qemu_comm_method="monitor" 59 59 60 - _launch_qemu \ 61 - -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk 60 + if [ "$IMGOPTSSYNTAX" = "true" ]; then 61 + _launch_qemu \ 62 + -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk 63 + else 64 + _launch_qemu \ 65 + -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk 66 + fi 62 67 src=$QEMU_HANDLE 63 68 64 - _launch_qemu \ 65 - -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk \ 66 - -incoming "unix:${MIG_SOCKET}" 69 + if [ "$IMGOPTSSYNTAX" = "true" ]; then 70 + _launch_qemu \ 71 + -drive "${TEST_IMG}",cache=${CACHEMODE},id=disk \ 72 + -incoming "unix:${MIG_SOCKET}" 73 + else 74 + _launch_qemu \ 75 + -drive file="${TEST_IMG}",cache=${CACHEMODE},driver=$IMGFMT,id=disk \ 76 + -incoming "unix:${MIG_SOCKET}" 77 + fi 67 78 dest=$QEMU_HANDLE 68 79 69 80 echo
+7 -2
tests/qemu-iotests/common.qemu
··· 153 153 mkfifo "${fifo_out}" 154 154 mkfifo "${fifo_in}" 155 155 156 + object_options= 157 + if [ -n "$IMGKEYSECRET" ]; then 158 + object_options="--object secret,id=keysec0,data=$IMGKEYSECRET" 159 + fi 160 + 156 161 if [ -z "$keep_stderr" ]; then 157 162 QEMU_NEED_PID='y'\ 158 - ${QEMU} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ 163 + ${QEMU} ${object_options} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ 159 164 2>&1 \ 160 165 <"${fifo_in}" & 161 166 elif [ "$keep_stderr" = "y" ]; then 162 167 QEMU_NEED_PID='y'\ 163 - ${QEMU} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ 168 + ${QEMU} ${object_options} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \ 164 169 <"${fifo_in}" & 165 170 else 166 171 exit 1