[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v12 09/16] iotests: 085: Avoid image locking conflic
From: |
Fam Zheng |
Subject: |
[Qemu-block] [PATCH v12 09/16] iotests: 085: Avoid image locking conflict |
Date: |
Mon, 23 Jan 2017 20:30:49 +0800 |
In the case where we test the expected error when a blockdev-snapshot
target already has a backing image, backing chain is opened multiple
times. This will be a problem when we use image locking, so use a
different backing file that is not already open.
Signed-off-by: Fam Zheng <address@hidden>
---
tests/qemu-iotests/085 | 32 +++++++++++++++++++-------------
tests/qemu-iotests/085.out | 3 ++-
2 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085
index c53e97f..c91d78d 100755
--- a/tests/qemu-iotests/085
+++ b/tests/qemu-iotests/085
@@ -87,24 +87,26 @@ function create_group_snapshot()
}
# ${1}: unique identifier for the snapshot filename
-# ${2}: true: open backing images; false: don't open them (default)
+# ${2}: extra_params to the blockdev-add command
+# ${3}: filename
+function do_blockdev_add()
+{
+ cmd="{ 'execute': 'blockdev-add', 'arguments':
+ { 'driver': 'qcow2', 'node-name': 'snap_${1}', ${2}
+ 'file':
+ { 'driver': 'file', 'filename': '${3}',
+ 'node-name': 'file_${1}' } } }"
+ _send_qemu_cmd $h "${cmd}" "return"
+}
+
+# ${1}: unique identifier for the snapshot filename
function add_snapshot_image()
{
- if [ "${2}" = "true" ]; then
- extra_params=""
- else
- extra_params="'backing': '', "
- fi
base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}"
snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}"
_make_test_img -b "${base_image}" "$size"
mv "${TEST_IMG}" "${snapshot_file}"
- cmd="{ 'execute': 'blockdev-add', 'arguments':
- { 'driver': 'qcow2', 'node-name': 'snap_${1}', ${extra_params}
- 'file':
- { 'driver': 'file', 'filename': '${snapshot_file}',
- 'node-name': 'file_${1}' } } }"
- _send_qemu_cmd $h "${cmd}" "return"
+ do_blockdev_add "$1" "'backing': '', " "${snapshot_file}"
}
# ${1}: unique identifier for the snapshot filename
@@ -222,7 +224,11 @@ echo === Invalid command - snapshot node has a backing
image ===
echo
SNAPSHOTS=$((${SNAPSHOTS}+1))
-add_snapshot_image ${SNAPSHOTS} true
+
+_make_test_img "$size"
+mv "${TEST_IMG}" "${TEST_IMG}.base"
+_make_test_img -b "${TEST_IMG}.base" "$size"
+do_blockdev_add ${SNAPSHOTS} "" "${TEST_IMG}"
blockdev_snapshot ${SNAPSHOTS} error
echo
diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out
index 08e4bb7..7bbf84d 100644
--- a/tests/qemu-iotests/085.out
+++ b/tests/qemu-iotests/085.out
@@ -78,7 +78,8 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
backing_file=TEST_DIR/
=== Invalid command - snapshot node has a backing image ===
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
backing_file=TEST_DIR/12-snapshot-v0.IMGFMT
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
backing_file=TEST_DIR/t.IMGFMT.base
{"return": {}}
{"error": {"class": "GenericError", "desc": "The snapshot already has a
backing image"}}
--
2.9.3
- [Qemu-block] [PATCH v12 00/16] block: Image locking series, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 02/16] block: Define BDRV_O_SHARE_RW, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 01/16] osdep: Add qemu_lock_fd and qemu_unlock_fd, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 03/16] qemu-io: Set "share-rw" flag together with read-only, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 04/16] qemu-img: Set "share-rw" flag in read-only commands, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 05/16] block: Set "share-rw" flag in drive-backup when sync=none, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 06/16] iotests: 055: Don't attach the drive to vm for drive-backup, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 07/16] iotests: 030: Read-only open image for getting map, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 08/16] iotests: 087: Don't attach test image twice, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 09/16] iotests: 085: Avoid image locking conflict,
Fam Zheng <=
- [Qemu-block] [PATCH v12 10/16] iotests: 091: Quit QEMU before checking image, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 11/16] iotests: 172: Use separate images for multiple devices, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 12/16] tests: Use null-co:// instead of /dev/null as the dummy image, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 13/16] tests: Disable image lock in test-replication, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 14/16] file-posix: Implement image locking, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 15/16] qcow2: Force "no other writer" lock on bs->file, Fam Zheng, 2017/01/23
- [Qemu-block] [PATCH v12 16/16] tests: Add test-image-lock, Fam Zheng, 2017/01/23