diff options
author | Max Reitz <mreitz@redhat.com> | 2018-05-09 23:53:36 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2018-06-11 16:18:45 +0200 |
commit | f45b638f9f967cdbea4e24704bd16a858ddcde03 (patch) | |
tree | c55ad38826998619b3768fa17339b783f0104b49 /tests/qemu-iotests/153 | |
parent | b8cf1913a989b9ea6f248aaa233330047a62962e (diff) |
iotests: Add creation test to 153
This patch adds a test case to 153 which tries to overwrite an image
(using qemu-img create) while it is in use. Without the original user
explicitly sharing the necessary permissions (writing and truncation),
this should not be allowed.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Message-id: 20180509215336.31304-4-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/153')
-rwxr-xr-x | tests/qemu-iotests/153 | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 index ec508c758f..673813cd39 100755 --- a/tests/qemu-iotests/153 +++ b/tests/qemu-iotests/153 @@ -137,6 +137,24 @@ for opts1 in "" "read-only=on" "read-only=on,force-share=on"; do _run_cmd $QEMU_IMG dd $L if="${TEST_IMG}" of="${TEST_IMG}.convert" bs=512 count=1 _run_cmd $QEMU_IMG bench $L -c 1 "${TEST_IMG}" _run_cmd $QEMU_IMG bench $L -w -c 1 "${TEST_IMG}" + + # qemu-img create does not support -U + if [ -z "$L" ]; then + _run_cmd $QEMU_IMG create -f $IMGFMT "${TEST_IMG}" \ + -b ${TEST_IMG}.base + # Read the file format. It used to be the case that + # file-posix simply truncated the file, but the qcow2 + # driver then failed to format it because it was unable + # to acquire the necessary WRITE permission. However, the + # truncation was already wrong, and the whole process + # resulted in the file being completely empty and thus its + # format would be detected to be raw. + # So we read it here to see that creation either completed + # successfully (thus the format is qcow2) or it aborted + # before the file was changed at all (thus the format stays + # qcow2). + _img_info -U | grep 'file format' + fi done _send_qemu_cmd $h "{ 'execute': 'quit', }" "" echo |