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

qemu-iotests: Add basic ability to use binary sample images

For image formats that are not "QEMU native", but supported for
compatibility, it is useful to verify that an image created with
the 'gold standard' native tool can be read / written to successfully
by QEMU.

In addition to testing non-native images, this could also be useful to
test against image files created by older versions of QEMU.

This provides a directory to store small sample images, for use by
scripts in tests/qemu-iotests.

Image files should be compressed with bzip2.

To use a sample image from a bash script, the _use_sample_img function
will copy and decompress the image into $TEST_DIR, and set $TEST_IMG to
be the decompressed sample image copy. To cleanup, call
_cleanup_test_img as normal.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>

authored by

Jeff Cody and committed by
Kevin Wolf
85edbd37 212774c5

+35
+11
tests/qemu-iotests/common.config
··· 125 125 126 126 export TEST_DIR 127 127 128 + if [ -z "$SAMPLE_IMG_DIR" ]; then 129 + SAMPLE_IMG_DIR=`pwd`/sample_images 130 + fi 131 + 132 + if [ ! -d "$SAMPLE_IMG_DIR" ]; then 133 + echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory" 134 + exit 1 135 + fi 136 + 137 + export SAMPLE_IMG_DIR 138 + 128 139 _readlink() 129 140 { 130 141 if [ $# -ne 1 ]; then
+16
tests/qemu-iotests/common.rc
··· 91 91 fi 92 92 } 93 93 94 + _use_sample_img() 95 + { 96 + SAMPLE_IMG_FILE="${1%\.bz2}" 97 + TEST_IMG="$TEST_DIR/$SAMPLE_IMG_FILE" 98 + bzcat "$SAMPLE_IMG_DIR/$1" > "$TEST_IMG" 99 + if [ $? -ne 0 ] 100 + then 101 + echo "_use_sample_img error, cannot extract '$SAMPLE_IMG_DIR/$1'" 102 + exit 1 103 + fi 104 + } 105 + 94 106 _make_test_img() 95 107 { 96 108 # extra qemu-img options can be added by tests ··· 158 170 rm -f $TEST_DIR/t.$IMGFMT 159 171 rm -f $TEST_DIR/t.$IMGFMT.orig 160 172 rm -f $TEST_DIR/t.$IMGFMT.base 173 + if [ -n "$SAMPLE_IMG_FILE" ] 174 + then 175 + rm -f "$TEST_DIR/$SAMPLE_IMG_FILE" 176 + fi 161 177 ;; 162 178 163 179 rbd)
+8
tests/qemu-iotests/sample_images/README
··· 1 + This is for small sample images to be used with qemu-iotests, intended for 2 + non-native formats that QEMU supports for compatibility. The idea is to use 3 + the native tool to create the sample image. 4 + 5 + For instance, a VHDX image in this directory would be an image created not by 6 + QEMU itself, but rather created by Hyper-V. 7 + 8 + Sample images added here must be compressed with bzip2.