From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, vsementsov@virtuozzo.com,
qemu-devel@nongnu.org, mreitz@redhat.com
Subject: [PATCH 1/8] iotests: handle tmpfs
Date: Thu, 30 Apr 2020 15:47:06 +0300 [thread overview]
Message-ID: <20200430124713.3067-2-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20200430124713.3067-1-vsementsov@virtuozzo.com>
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>
---
tests/qemu-iotests/091 | 2 +-
tests/qemu-iotests/common.rc | 37 ++++++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
index d2a2aca347..68fbfd777b 100755
--- a/tests/qemu-iotests/091
+++ b/tests/qemu-iotests/091
@@ -46,8 +46,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt qcow2
_supported_proto file
_supported_os Linux
-_default_cache_mode none
_supported_cache_modes writethrough none writeback
+_default_cache_mode none writeback
size=1G
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index bf3b9fdea0..ba912555ca 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -673,11 +673,44 @@ _supported_cache_modes()
_notrun "not suitable for cache mode: $CACHEMODE"
}
+# Check whether the filesystem supports O_DIRECT
+_check_o_direct()
+{
+ $QEMU_IMG create -f raw "$TEST_IMG".test_o_direct 1M > /dev/null
+ out=$($QEMU_IO -f raw -t none -c quit "$TEST_IMG".test_o_direct 2>&1)
+ rm -f "$TEST_IMG".test_o_direct
+
+ [[ "$out" != *"O_DIRECT"* ]]
+}
+
+_require_o_direct()
+{
+ if ! _check_o_direct; then
+ _notrun "file system on $TEST_DIR does not support O_DIRECT"
+ fi
+}
+
+_check_cache_mode()
+{
+ if [ $CACHEMODE == "none" ] || [ $CACHEMODE == "directsync" ]; then
+ _require_o_direct
+ fi
+}
+
+_check_cache_mode
+
+# $1 - cache mode to use by default
+# $2 - (optional) cache mode to use by default if O_DIRECT is not supported
_default_cache_mode()
{
if $CACHEMODE_IS_DEFAULT; then
- CACHEMODE="$1"
- QEMU_IO="$QEMU_IO --cache $1"
+ if [ -z "$2" ] || _check_o_direct; then
+ CACHEMODE="$1"
+ else
+ CACHEMODE="$2"
+ fi
+ QEMU_IO="$QEMU_IO --cache $CACHEMODE"
+ _check_cache_mode
return
fi
}
--
2.21.0
next prev parent reply other threads:[~2020-04-30 12:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-30 12:47 [PATCH 0/8] iotests skipping Vladimir Sementsov-Ogievskiy
2020-04-30 12:47 ` Vladimir Sementsov-Ogievskiy [this message]
2020-04-30 12:47 ` [PATCH 2/8] iotests/082: require bochs Vladimir Sementsov-Ogievskiy
2020-04-30 12:47 ` [PATCH 3/8] iotests/148: use skip_if_unsupported Vladimir Sementsov-Ogievskiy
2020-04-30 12:47 ` [PATCH 4/8] iotests/041: drop self.assert_no_active_block_jobs() Vladimir Sementsov-Ogievskiy
2020-04-30 12:47 ` [PATCH 5/8] iotests/055: refactor compressed backup to vmdk Vladimir Sementsov-Ogievskiy
2020-04-30 12:47 ` [PATCH 6/8] iotests/055: skip vmdk target tests if vmdk is not whitelisted Vladimir Sementsov-Ogievskiy
2020-04-30 12:47 ` [PATCH 7/8] iotests/109: mark required formats as required to support whitelisting Vladimir Sementsov-Ogievskiy
2020-04-30 12:47 ` [PATCH 8/8] iotests/113: mark bochs " Vladimir Sementsov-Ogievskiy
2020-05-04 16:32 ` [PATCH 0/8] iotests skipping Kevin Wolf
2020-05-06 6:11 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200430124713.3067-2-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.