summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell2020-05-08 15:29:18 +0200
committerPeter Maydell2020-05-08 15:29:18 +0200
commitc88f1ffc19e38008a1c33ae039482a860aa7418c (patch)
treedb26706712a4f9db926275ffa5a52a88b63a2a3e /tests
parentMerge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20200507a'... (diff)
parentblock: Drop unused .bdrv_has_zero_init_truncate (diff)
downloadqemu-c88f1ffc19e38008a1c33ae039482a860aa7418c.tar.gz
qemu-c88f1ffc19e38008a1c33ae039482a860aa7418c.tar.xz
qemu-c88f1ffc19e38008a1c33ae039482a860aa7418c.zip
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - qcow2: Fix preallocation on block devices - backup: Make sure that source and target size match - vmdk: Fix zero cluster handling - Follow-up cleanups and fixes for the truncate changes - iotests: Skip more tests if required drivers are missing # gpg: Signature made Fri 08 May 2020 13:39:55 BST # gpg: using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6 # gpg: issuer "kwolf@redhat.com" # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: (30 commits) block: Drop unused .bdrv_has_zero_init_truncate vhdx: Rework truncation logic parallels: Rework truncation logic ssh: Support BDRV_REQ_ZERO_WRITE for truncate sheepdog: Support BDRV_REQ_ZERO_WRITE for truncate rbd: Support BDRV_REQ_ZERO_WRITE for truncate nfs: Support BDRV_REQ_ZERO_WRITE for truncate file-win32: Support BDRV_REQ_ZERO_WRITE for truncate gluster: Drop useless has_zero_init callback qcow2: Fix preallocation on block devices iotests/055: Use cache.no-flush for vmdk target iotests: Backup with different source/target size backup: Make sure that source and target size match backup: Improve error for bdrv_getlength() failure iotests/283: Use consistent size for source and target iotests: vmdk: Enable zeroed_grained=on by default vmdk: Flush only once in vmdk_L2update() vmdk: Don't update L2 table for zero write on zero cluster vmdk: Fix partial overwrite of zero cluster vmdk: Fix zero cluster allocation ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/qemu-iotests/0418
-rwxr-xr-xtests/qemu-iotests/055120
-rw-r--r--tests/qemu-iotests/055.out4
-rwxr-xr-xtests/qemu-iotests/0596
-rwxr-xr-xtests/qemu-iotests/0821
-rwxr-xr-xtests/qemu-iotests/0912
-rwxr-xr-xtests/qemu-iotests/1091
-rwxr-xr-xtests/qemu-iotests/1134
-rwxr-xr-xtests/qemu-iotests/1481
-rw-r--r--tests/qemu-iotests/2836
-rw-r--r--tests/qemu-iotests/283.out2
-rwxr-xr-xtests/qemu-iotests/29273
-rw-r--r--tests/qemu-iotests/292.out24
-rwxr-xr-xtests/qemu-iotests/check3
-rw-r--r--tests/qemu-iotests/common.rc37
-rw-r--r--tests/qemu-iotests/group1
16 files changed, 237 insertions, 56 deletions
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index 46bf1f6c81..1812dd8479 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -904,8 +904,6 @@ class TestRepairQuorum(iotests.QMPTestCase):
pass
def test_complete(self):
- self.assert_no_active_block_jobs()
-
result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0',
sync='full', node_name="repair0", replaces="img1",
target=quorum_repair_img, format=iotests.imgfmt)
@@ -919,8 +917,6 @@ class TestRepairQuorum(iotests.QMPTestCase):
'target image does not match source after mirroring')
def test_cancel(self):
- self.assert_no_active_block_jobs()
-
result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0',
sync='full', node_name="repair0", replaces="img1",
target=quorum_repair_img, format=iotests.imgfmt)
@@ -932,8 +928,6 @@ class TestRepairQuorum(iotests.QMPTestCase):
self.assert_has_block_node(None, quorum_img3)
def test_cancel_after_ready(self):
- self.assert_no_active_block_jobs()
-
result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0',
sync='full', node_name="repair0", replaces="img1",
target=quorum_repair_img, format=iotests.imgfmt)
@@ -948,8 +942,6 @@ class TestRepairQuorum(iotests.QMPTestCase):
'target image does not match source after mirroring')
def test_pause(self):
- self.assert_no_active_block_jobs()
-
result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0',
sync='full', node_name="repair0", replaces="img1",
target=quorum_repair_img, format=iotests.imgfmt)
diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055
index 4175fff5e4..4d3744b0d3 100755
--- a/tests/qemu-iotests/055
+++ b/tests/qemu-iotests/055
@@ -48,8 +48,10 @@ class TestSingleDrive(iotests.QMPTestCase):
def setUp(self):
qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(image_len))
- self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
- self.vm.add_drive(blockdev_target_img, interface="none")
+ self.vm = iotests.VM()
+ self.vm.add_drive('blkdebug::' + test_img, 'node-name=source')
+ self.vm.add_drive(blockdev_target_img, 'node-name=target',
+ interface="none")
if iotests.qemu_default_machine == 'pc':
self.vm.add_drive(None, 'media=cdrom', 'ide')
self.vm.launch()
@@ -112,6 +114,41 @@ class TestSingleDrive(iotests.QMPTestCase):
def test_pause_blockdev_backup(self):
self.do_test_pause('blockdev-backup', 'drive1', blockdev_target_img)
+ def do_test_resize_blockdev_backup(self, device, node):
+ def pre_finalize():
+ result = self.vm.qmp('block_resize', device=device, size=65536)
+ self.assert_qmp(result, 'error/class', 'GenericError')
+
+ result = self.vm.qmp('block_resize', node_name=node, size=65536)
+ self.assert_qmp(result, 'error/class', 'GenericError')
+
+ result = self.vm.qmp('blockdev-backup', job_id='job0', device='drive0',
+ target='drive1', sync='full', auto_finalize=False,
+ auto_dismiss=False)
+ self.assert_qmp(result, 'return', {})
+
+ self.vm.run_job('job0', auto_finalize=False, pre_finalize=pre_finalize)
+
+ def test_source_resize_blockdev_backup(self):
+ self.do_test_resize_blockdev_backup('drive0', 'source')
+
+ def test_target_resize_blockdev_backup(self):
+ self.do_test_resize_blockdev_backup('drive1', 'target')
+
+ def do_test_target_size(self, size):
+ result = self.vm.qmp('block_resize', device='drive1', size=size)
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.qmp('blockdev-backup', job_id='job0', device='drive0',
+ target='drive1', sync='full')
+ self.assert_qmp(result, 'error/class', 'GenericError')
+
+ def test_small_target(self):
+ self.do_test_target_size(image_len // 2)
+
+ def test_large_target(self):
+ self.do_test_target_size(image_len * 2)
+
def test_medium_not_found(self):
if iotests.qemu_default_machine != 'pc':
return
@@ -450,10 +487,9 @@ class TestSingleTransaction(iotests.QMPTestCase):
self.assert_no_active_block_jobs()
-class TestDriveCompression(iotests.QMPTestCase):
+class TestCompressedToQcow2(iotests.QMPTestCase):
image_len = 64 * 1024 * 1024 # MB
- fmt_supports_compression = [{'type': 'qcow2', 'args': ()},
- {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized')}]
+ target_fmt = {'type': 'qcow2', 'args': (), 'drive-opts': ''}
def tearDown(self):
self.vm.shutdown()
@@ -463,19 +499,22 @@ class TestDriveCompression(iotests.QMPTestCase):
except OSError:
pass
- def do_prepare_drives(self, fmt, args, attach_target):
- self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
+ def do_prepare_drives(self, attach_target):
+ self.vm = iotests.VM().add_drive('blkdebug::' + test_img,
+ opts=self.target_fmt['drive-opts'])
- qemu_img('create', '-f', fmt, blockdev_target_img,
- str(TestDriveCompression.image_len), *args)
+ qemu_img('create', '-f', self.target_fmt['type'], blockdev_target_img,
+ str(self.image_len), *self.target_fmt['args'])
if attach_target:
self.vm.add_drive(blockdev_target_img,
- img_format=fmt, interface="none")
+ img_format=self.target_fmt['type'],
+ interface="none",
+ opts=self.target_fmt['drive-opts'])
self.vm.launch()
- def do_test_compress_complete(self, cmd, format, attach_target, **args):
- self.do_prepare_drives(format['type'], format['args'], attach_target)
+ def do_test_compress_complete(self, cmd, attach_target, **args):
+ self.do_prepare_drives(attach_target)
self.assert_no_active_block_jobs()
@@ -486,21 +525,21 @@ class TestDriveCompression(iotests.QMPTestCase):
self.vm.shutdown()
self.assertTrue(iotests.compare_images(test_img, blockdev_target_img,
- iotests.imgfmt, format['type']),
+ iotests.imgfmt,
+ self.target_fmt['type']),
'target image does not match source after backup')
def test_complete_compress_drive_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_complete('drive-backup', format, False,
- target=blockdev_target_img, mode='existing')
+ self.do_test_compress_complete('drive-backup', False,
+ target=blockdev_target_img,
+ mode='existing')
def test_complete_compress_blockdev_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_complete('blockdev-backup', format, True,
- target='drive1')
+ self.do_test_compress_complete('blockdev-backup',
+ True, target='drive1')
- def do_test_compress_cancel(self, cmd, format, attach_target, **args):
- self.do_prepare_drives(format['type'], format['args'], attach_target)
+ def do_test_compress_cancel(self, cmd, attach_target, **args):
+ self.do_prepare_drives(attach_target)
self.assert_no_active_block_jobs()
@@ -514,17 +553,16 @@ class TestDriveCompression(iotests.QMPTestCase):
self.vm.shutdown()
def test_compress_cancel_drive_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_cancel('drive-backup', format, False,
- target=blockdev_target_img, mode='existing')
+ self.do_test_compress_cancel('drive-backup', False,
+ target=blockdev_target_img,
+ mode='existing')
def test_compress_cancel_blockdev_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_cancel('blockdev-backup', format, True,
- target='drive1')
+ self.do_test_compress_cancel('blockdev-backup', True,
+ target='drive1')
- def do_test_compress_pause(self, cmd, format, attach_target, **args):
- self.do_prepare_drives(format['type'], format['args'], attach_target)
+ def do_test_compress_pause(self, cmd, attach_target, **args):
+ self.do_prepare_drives(attach_target)
self.assert_no_active_block_jobs()
@@ -550,18 +588,28 @@ class TestDriveCompression(iotests.QMPTestCase):
self.vm.shutdown()
self.assertTrue(iotests.compare_images(test_img, blockdev_target_img,
- iotests.imgfmt, format['type']),
+ iotests.imgfmt,
+ self.target_fmt['type']),
'target image does not match source after backup')
def test_compress_pause_drive_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_pause('drive-backup', format, False,
- target=blockdev_target_img, mode='existing')
+ self.do_test_compress_pause('drive-backup', False,
+ target=blockdev_target_img,
+ mode='existing')
def test_compress_pause_blockdev_backup(self):
- for format in TestDriveCompression.fmt_supports_compression:
- self.do_test_compress_pause('blockdev-backup', format, True,
- target='drive1')
+ self.do_test_compress_pause('blockdev-backup', True,
+ target='drive1')
+
+
+class TestCompressedToVmdk(TestCompressedToQcow2):
+ target_fmt = {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized'),
+ 'drive-opts': 'cache.no-flush=on'}
+
+ @iotests.skip_if_unsupported(['vmdk'])
+ def setUp(self):
+ pass
+
if __name__ == '__main__':
iotests.main(supported_fmts=['raw', 'qcow2'],
diff --git a/tests/qemu-iotests/055.out b/tests/qemu-iotests/055.out
index 5ce2f9a2ed..0a5e9583a4 100644
--- a/tests/qemu-iotests/055.out
+++ b/tests/qemu-iotests/055.out
@@ -1,5 +1,5 @@
-..............................
+........................................
----------------------------------------------------------------------
-Ran 30 tests
+Ran 40 tests
OK
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
index 5438025285..4c90fc0363 100755
--- a/tests/qemu-iotests/059
+++ b/tests/qemu-iotests/059
@@ -41,9 +41,9 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt vmdk
_supported_proto file
_supported_os Linux
-_unsupported_imgopts "subformat=monolithicFlat" \
- "subformat=twoGbMaxExtentFlat" \
- "subformat=twoGbMaxExtentSparse"
+
+# We test all kinds of VMDK options here, so ignore user-specified options
+IMGOPTS=""
capacity_offset=16
granularity_offset=20
diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082
index 3286c2c6db..1998965ed4 100755
--- a/tests/qemu-iotests/082
+++ b/tests/qemu-iotests/082
@@ -38,6 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt qcow2
_supported_proto file nfs
+_require_drivers bochs
run_qemu_img()
{
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/109 b/tests/qemu-iotests/109
index a51dd84b3d..5bc2e9b001 100755
--- a/tests/qemu-iotests/109
+++ b/tests/qemu-iotests/109
@@ -42,6 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
_supported_fmt raw
_supported_proto file
_supported_os Linux
+_require_drivers qcow qcow2 qed vdi vmdk vpc
qemu_comm_method=qmp
diff --git a/tests/qemu-iotests/113 b/tests/qemu-iotests/113
index f2703a2c50..71a65de2e7 100755
--- a/tests/qemu-iotests/113
+++ b/tests/qemu-iotests/113
@@ -37,8 +37,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
. ./common.rc
. ./common.filter
-# Some of these test cases use bochs, but others do use raw, so this
-# is only half a lie.
+# Some of these test cases use bochs, but others do use raw
+_require_drivers bochs
_supported_fmt raw
_supported_proto file
_supported_os Linux
diff --git a/tests/qemu-iotests/148 b/tests/qemu-iotests/148
index 90931948e3..5e14a455b1 100755
--- a/tests/qemu-iotests/148
+++ b/tests/qemu-iotests/148
@@ -47,6 +47,7 @@ sector = "%d"
''' % bad_sector)
file.close()
+ @iotests.skip_if_unsupported(['quorum'])
def setUp(self):
driveopts = ['driver=quorum', 'vote-threshold=2']
driveopts.append('read-pattern=%s' % self.read_pattern)
diff --git a/tests/qemu-iotests/283 b/tests/qemu-iotests/283
index e17b953333..383797ed62 100644
--- a/tests/qemu-iotests/283
+++ b/tests/qemu-iotests/283
@@ -74,7 +74,11 @@ to check that crash is fixed :)
vm = iotests.VM()
vm.launch()
-vm.qmp_log('blockdev-add', **{'node-name': 'target', 'driver': 'null-co'})
+vm.qmp_log('blockdev-add', **{
+ 'node-name': 'target',
+ 'driver': 'null-co',
+ 'size': size,
+})
vm.qmp_log('blockdev-add', **{
'node-name': 'source',
diff --git a/tests/qemu-iotests/283.out b/tests/qemu-iotests/283.out
index daaf5828c1..d8cff22cc1 100644
--- a/tests/qemu-iotests/283.out
+++ b/tests/qemu-iotests/283.out
@@ -1,4 +1,4 @@
-{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "target"}}
+{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "target", "size": 1048576}}
{"return": {}}
{"execute": "blockdev-add", "arguments": {"driver": "blkdebug", "image": {"driver": "null-co", "node-name": "base", "size": 1048576}, "node-name": "source"}}
{"return": {}}
diff --git a/tests/qemu-iotests/292 b/tests/qemu-iotests/292
new file mode 100755
index 0000000000..a2de27cca4
--- /dev/null
+++ b/tests/qemu-iotests/292
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+#
+# Test resizing a qcow2 image with a backing file
+#
+# Copyright (C) 2020 Igalia, S.L.
+# Author: Alberto Garcia <berto@igalia.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+# creator
+owner=berto@igalia.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+status=1 # failure is the default!
+
+_cleanup()
+{
+ _cleanup_test_img
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_supported_fmt qcow2
+_supported_proto file
+_supported_os Linux
+
+echo '### Create the backing image'
+BACKING_IMG="$TEST_IMG.base"
+TEST_IMG="$BACKING_IMG" _make_test_img 1M
+
+echo '### Fill the backing image with data (0x11)'
+$QEMU_IO -c 'write -P 0x11 0 1M' "$BACKING_IMG" | _filter_qemu_io
+
+echo '### Create the top image'
+_make_test_img -F "$IMGFMT" -b "$BACKING_IMG"
+
+echo '### Fill the top image with data (0x22)'
+$QEMU_IO -c 'write -P 0x22 0 1M' "$TEST_IMG" | _filter_qemu_io
+
+# Both offsets are part of the same cluster.
+echo '### Shrink the image to 520k'
+$QEMU_IMG resize --shrink "$TEST_IMG" 520k
+echo '### Grow the image to 567k'
+$QEMU_IMG resize "$TEST_IMG" 567k
+
+echo '### Check that the tail of the image reads as zeroes'
+$QEMU_IO -c 'read -P 0x22 0 520k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 520k 47k' "$TEST_IMG" | _filter_qemu_io
+
+echo '### Show output of qemu-img map'
+$QEMU_IMG map "$TEST_IMG" | _filter_testdir
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
diff --git a/tests/qemu-iotests/292.out b/tests/qemu-iotests/292.out
new file mode 100644
index 0000000000..807e0530c3
--- /dev/null
+++ b/tests/qemu-iotests/292.out
@@ -0,0 +1,24 @@
+QA output created by 292
+### Create the backing image
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=1048576
+### Fill the backing image with data (0x11)
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+### Create the top image
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
+### Fill the top image with data (0x22)
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+### Shrink the image to 520k
+Image resized.
+### Grow the image to 567k
+Image resized.
+### Check that the tail of the image reads as zeroes
+read 532480/532480 bytes at offset 0
+520 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 48128/48128 bytes at offset 532480
+47 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+### Show output of qemu-img map
+Offset Length Mapped to File
+0 0x8dc00 0x50000 TEST_DIR/t.qcow2
+*** done
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index f7a2d3d6c3..9c461cf76d 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -546,6 +546,9 @@ fi
if [ "$IMGFMT" == "luks" ] && ! (echo "$IMGOPTS" | grep "iter-time=" > /dev/null); then
IMGOPTS=$(_optstr_add "$IMGOPTS" "iter-time=10")
fi
+if [ "$IMGFMT" == "vmdk" ] && ! (echo "$IMGOPTS" | grep "zeroed_grain=" > /dev/null); then
+ IMGOPTS=$(_optstr_add "$IMGOPTS" "zeroed_grain=on")
+fi
if [ -z "$SAMPLE_IMG_DIR" ]; then
SAMPLE_IMG_DIR="$source_iotests/sample_images"
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
}
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 1710470e70..fe649c5b73 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -298,3 +298,4 @@
288 quick
289 rw quick
290 rw auto quick
+292 rw auto quick