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

iotest 033: add misaligned write-zeroes test via truncate

This new test case only makes sense for qcow2 while iotest 033 is generic;
however it matches the test purpose perfectly and also 033 contains those
do_test() tricks to pass the alignment, which won't look nice being
duplicated in other tests or moved to the common code.

Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>

authored by

Anton Nefedov and committed by
Kevin Wolf
afe35cde 18a59f03

+42
+29
tests/qemu-iotests/033
··· 64 64 } | $QEMU_IO $IO_EXTRA_ARGS 65 65 } 66 66 67 + echo 68 + echo "=== Test aligned and misaligned write zeroes operations ===" 69 + 67 70 for write_zero_cmd in "write -z" "aio_write -z"; do 68 71 for align in 512 4k; do 69 72 echo ··· 102 105 done 103 106 done 104 107 108 + 109 + # Trigger truncate that would shrink qcow2 L1 table, which is done by 110 + # clearing one entry (8 bytes) with bdrv_co_pwrite_zeroes() 111 + 112 + echo 113 + echo "=== Test misaligned write zeroes via truncate ===" 114 + echo 115 + 116 + # any size will do, but the smaller the size the smaller the required image 117 + CLUSTER_SIZE=$((4 * 1024)) 118 + L2_COVERAGE=$(($CLUSTER_SIZE * $CLUSTER_SIZE / 8)) 119 + _make_test_img $(($L2_COVERAGE * 2)) 120 + 121 + do_test 512 "write -P 1 0 0x200" "$TEST_IMG" | _filter_qemu_io 122 + # next L2 table 123 + do_test 512 "write -P 1 $L2_COVERAGE 0x200" "$TEST_IMG" | _filter_qemu_io 124 + 125 + # only interested in qcow2 here; also other formats might respond with 126 + # "not supported" error message 127 + if [ $IMGFMT = "qcow2" ]; then 128 + do_test 512 "truncate $L2_COVERAGE" "$TEST_IMG" | _filter_qemu_io 129 + fi 130 + 131 + do_test 512 "read -P 1 0 0x200" "$TEST_IMG" | _filter_qemu_io 132 + 105 133 # success, all done 134 + echo 106 135 echo "*** done" 107 136 rm -f $seq.full 108 137 status=0
+13
tests/qemu-iotests/033.out
··· 1 1 QA output created by 033 2 2 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 3 3 4 + === Test aligned and misaligned write zeroes operations === 5 + 4 6 == preparing image == 5 7 wrote 1024/1024 bytes at offset 512 6 8 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) ··· 163 165 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 164 166 read 3072/3072 bytes at offset 1024 165 167 3 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 168 + 169 + 170 + === Test misaligned write zeroes via truncate === 171 + 172 + Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 173 + wrote 512/512 bytes at offset 0 174 + 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 175 + wrote 512/512 bytes at offset 2097152 176 + 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 177 + read 512/512 bytes at offset 0 178 + 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 166 179 167 180 *** done