aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/182
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2018-11-16 17:45:26 +0100
committerKevin Wolf <kwolf@redhat.com>2018-11-19 14:32:04 +0100
commit6d0a4a0fb5c8f10c8eb68b52cfda0082b00ae963 (patch)
tree760811e8b5928efe654de6c95cf798baeeae0ed6 /tests/qemu-iotests/182
parent577a133988c76e4ebf01d050d0d758d207a1baf7 (diff)
downloadqemu-6d0a4a0fb5c8f10c8eb68b52cfda0082b00ae963.zip
qemu-6d0a4a0fb5c8f10c8eb68b52cfda0082b00ae963.tar.gz
qemu-6d0a4a0fb5c8f10c8eb68b52cfda0082b00ae963.tar.bz2
iotests: Test file-posix locking and reopen
Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/182')
-rwxr-xr-xtests/qemu-iotests/18271
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/qemu-iotests/182 b/tests/qemu-iotests/182
index 4b31592..3b7689c 100755
--- a/tests/qemu-iotests/182
+++ b/tests/qemu-iotests/182
@@ -31,6 +31,7 @@ status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
+ rm -f "$TEST_IMG.overlay"
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -71,6 +72,76 @@ echo 'quit' | $QEMU -nographic -monitor stdio \
_cleanup_qemu
+echo
+echo '=== Testing reopen ==='
+echo
+
+# This tests that reopening does not unshare any permissions it should
+# not unshare
+# (There was a bug where reopening shared exactly the opposite of the
+# permissions it was supposed to share)
+
+_launch_qemu
+
+_send_qemu_cmd $QEMU_HANDLE \
+ "{'execute': 'qmp_capabilities'}" \
+ 'return'
+
+# Open the image without any format layer (we are not going to access
+# it, so that is fine)
+# This should keep all permissions shared.
+success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \
+ "{'execute': 'blockdev-add',
+ 'arguments': {
+ 'node-name': 'node0',
+ 'driver': 'file',
+ 'filename': '$TEST_IMG',
+ 'locking': 'on'
+ } }" \
+ 'return' \
+ 'error'
+
+# This snapshot will perform a reopen to drop R/W to RO.
+# It should still keep all permissions shared.
+success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \
+ "{'execute': 'blockdev-snapshot-sync',
+ 'arguments': {
+ 'node-name': 'node0',
+ 'snapshot-file': '$TEST_IMG.overlay',
+ 'snapshot-node-name': 'node1'
+ } }" \
+ 'return' \
+ 'error'
+
+# Now open the same file again
+# This does not require any permissions (and does not unshare any), so
+# this will not conflict with node0.
+success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \
+ "{'execute': 'blockdev-add',
+ 'arguments': {
+ 'node-name': 'node1',
+ 'driver': 'file',
+ 'filename': '$TEST_IMG',
+ 'locking': 'on'
+ } }" \
+ 'return' \
+ 'error'
+
+# Now we attach the image to a virtio-blk device. This device does
+# require some permissions (at least WRITE and READ_CONSISTENT), so if
+# reopening node0 unshared any (which it should not have), this will
+# fail (but it should not).
+success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \
+ "{'execute': 'device_add',
+ 'arguments': {
+ 'driver': 'virtio-blk',
+ 'drive': 'node1'
+ } }" \
+ 'return' \
+ 'error'
+
+_cleanup_qemu
+
# success, all done
echo "*** done"
rm -f $seq.full