[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/29] iotests: Add creation test to 153
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PULL 03/29] iotests: Add creation test to 153 |
Date: |
Mon, 11 Jun 2018 16:25:45 +0200 |
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 <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Signed-off-by: Max Reitz <address@hidden>
---
tests/qemu-iotests/153 | 18 ++++++++++++++++++
tests/qemu-iotests/153.out | 13 +++++++++++++
2 files changed, 31 insertions(+)
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
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
index 2510762ba1..3492ba7a29 100644
--- a/tests/qemu-iotests/153.out
+++ b/tests/qemu-iotests/153.out
@@ -92,6 +92,11 @@ _qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
Is another process using the image?
+_qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
+qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
+Is another process using the image?
+file format: IMGFMT
+
== Running utility commands -U ==
_qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2
@@ -209,6 +214,11 @@ _qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
Is another process using the image?
+_qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
+qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
+Is another process using the image?
+file format: IMGFMT
+
== Running utility commands -U ==
_qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2
@@ -309,6 +319,9 @@ _qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
_qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
+_qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
+file format: IMGFMT
+
== Running utility commands -U ==
_qemu_io_wrapper -U -c read 0 512 TEST_DIR/t.qcow2
--
2.17.1
- [Qemu-devel] [PULL 00/29] Block patches, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 02/29] block/file-posix: File locking during creation, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 01/29] block/file-posix: Pass FD to locking helpers, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 04/29] qemu-img: Amendment support implies create_opts, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 03/29] iotests: Add creation test to 153,
Max Reitz <=
- [Qemu-devel] [PULL 06/29] qemu-option: Pull out "Supported options" print, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 07/29] qemu-img: Add print_amend_option_help(), Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 09/29] iotests: Test help option for unsupporting formats, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 05/29] block: Add Error parameter to bdrv_amend_options, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 11/29] qcow2: Repair OFLAG_COPIED when fixing leaks, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 10/29] iotests: Rework 113, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 12/29] iotests: Repairing error during snapshot deletion, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 15/29] qemu-io: Exit with error when a command failed, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 08/29] qemu-img: Recognize no creation support in -o help, Max Reitz, 2018/06/11
- [Qemu-devel] [PULL 16/29] iotests.py: Add qemu_io_silent, Max Reitz, 2018/06/11