aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/244
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2019-11-13 17:26:07 +0100
committerKevin Wolf <kwolf@redhat.com>2020-09-07 12:31:31 +0200
commitc365625b0a7b44ad48dc9ab01605857c8d4cf2c3 (patch)
treee2d41d7cee6e7ccffc7e749b1ccc32a98b25c427 /tests/qemu-iotests/244
parent0b877d09df4557900149384d60be0e9c3d309105 (diff)
downloadqemu-c365625b0a7b44ad48dc9ab01605857c8d4cf2c3.zip
qemu-c365625b0a7b44ad48dc9ab01605857c8d4cf2c3.tar.gz
qemu-c365625b0a7b44ad48dc9ab01605857c8d4cf2c3.tar.bz2
iotests: Test that qcow2's data-file is flushed
Flushing a qcow2 node must lead to the data-file node being flushed as well. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/244')
-rwxr-xr-xtests/qemu-iotests/24449
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244
index efe3c04..f2b2ddd 100755
--- a/tests/qemu-iotests/244
+++ b/tests/qemu-iotests/244
@@ -217,6 +217,55 @@ $QEMU_IMG amend -f $IMGFMT -o "data_file=blkdebug::$TEST_IMG.data" "$TEST_IMG"
$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n -C "$TEST_IMG.src" "$TEST_IMG"
$QEMU_IMG compare -f $IMGFMT -F $IMGFMT "$TEST_IMG.src" "$TEST_IMG"
+echo
+echo "=== Flushing should flush the data file ==="
+echo
+
+# We are going to flush a qcow2 file with a blkdebug node inserted
+# between the qcow2 node and its data file node. The blkdebug node
+# will return an error for all flushes and so we if the data file is
+# flushed, we will see qemu-io return an error.
+
+# We need to write something or the flush will not do anything; we
+# also need -t writeback so the write is not done as a FUA write
+# (which would then fail thanks to the implicit flush)
+$QEMU_IO -c 'write 0 512' -c flush \
+ -t writeback \
+ "json:{
+ 'driver': 'qcow2',
+ 'file': {
+ 'driver': 'file',
+ 'filename': '$TEST_IMG'
+ },
+ 'data-file': {
+ 'driver': 'blkdebug',
+ 'inject-error': [{
+ 'event': 'none',
+ 'iotype': 'flush'
+ }],
+ 'image': {
+ 'driver': 'file',
+ 'filename': '$TEST_IMG.data'
+ }
+ }
+ }" \
+ | _filter_qemu_io
+
+result=${PIPESTATUS[0]}
+echo
+
+case $result in
+ 0)
+ echo "ERROR: qemu-io succeeded, so the data file was not flushed"
+ ;;
+ 1)
+ echo "Success: qemu-io failed, so the data file was flushed"
+ ;;
+ *)
+ echo "ERROR: qemu-io returned unknown exit code $result"
+ ;;
+esac
+
# success, all done
echo "*** done"
rm -f $seq.full