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

iotests: handle tmpfs

Some tests requires O_DIRECT, or want it by default. Introduce smarter
O_DIRECT handling:

- Check O_DIRECT in common.rc, if it is requested by selected
cache-mode.

- Support second fall-through argument in _default_cache_mode

Inspired-by: Max's 23e1d054112cec1e
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200430124713.3067-2-vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>

authored by

Vladimir Sementsov-Ogievskiy and committed by
Kevin Wolf
cfdca2b9 1b8c4589

+36 -3
+1 -1
tests/qemu-iotests/091
··· 46 46 _supported_fmt qcow2 47 47 _supported_proto file 48 48 _supported_os Linux 49 - _default_cache_mode none 50 49 _supported_cache_modes writethrough none writeback 50 + _default_cache_mode none writeback 51 51 52 52 size=1G 53 53
+35 -2
tests/qemu-iotests/common.rc
··· 673 673 _notrun "not suitable for cache mode: $CACHEMODE" 674 674 } 675 675 676 + # Check whether the filesystem supports O_DIRECT 677 + _check_o_direct() 678 + { 679 + $QEMU_IMG create -f raw "$TEST_IMG".test_o_direct 1M > /dev/null 680 + out=$($QEMU_IO -f raw -t none -c quit "$TEST_IMG".test_o_direct 2>&1) 681 + rm -f "$TEST_IMG".test_o_direct 682 + 683 + [[ "$out" != *"O_DIRECT"* ]] 684 + } 685 + 686 + _require_o_direct() 687 + { 688 + if ! _check_o_direct; then 689 + _notrun "file system on $TEST_DIR does not support O_DIRECT" 690 + fi 691 + } 692 + 693 + _check_cache_mode() 694 + { 695 + if [ $CACHEMODE == "none" ] || [ $CACHEMODE == "directsync" ]; then 696 + _require_o_direct 697 + fi 698 + } 699 + 700 + _check_cache_mode 701 + 702 + # $1 - cache mode to use by default 703 + # $2 - (optional) cache mode to use by default if O_DIRECT is not supported 676 704 _default_cache_mode() 677 705 { 678 706 if $CACHEMODE_IS_DEFAULT; then 679 - CACHEMODE="$1" 680 - QEMU_IO="$QEMU_IO --cache $1" 707 + if [ -z "$2" ] || _check_o_direct; then 708 + CACHEMODE="$1" 709 + else 710 + CACHEMODE="$2" 711 + fi 712 + QEMU_IO="$QEMU_IO --cache $CACHEMODE" 713 + _check_cache_mode 681 714 return 682 715 fi 683 716 }