aboutsummaryrefslogtreecommitdiff
path: root/tests/qemu-iotests/085
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2017-05-03 00:35:45 +0800
committerKevin Wolf <kwolf@redhat.com>2017-05-11 11:08:40 +0200
commitecffa634218c05813c4b055f73826d09d7f07346 (patch)
tree5ebf0331fe1a5975c31227d615d24da28a51f3c1 /tests/qemu-iotests/085
parent4797aeabdc61d7bbf9ef0cb9e25fb539912bb7f3 (diff)
downloadqemu-ecffa634218c05813c4b055f73826d09d7f07346.zip
qemu-ecffa634218c05813c4b055f73826d09d7f07346.tar.gz
qemu-ecffa634218c05813c4b055f73826d09d7f07346.tar.bz2
iotests: 085: Avoid image locking conflict
In the case where we test the expected error when a blockdev-snapshot target already has a backing image, the 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 <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'tests/qemu-iotests/085')
-rwxr-xr-xtests/qemu-iotests/08533
1 files changed, 19 insertions, 14 deletions
diff --git a/tests/qemu-iotests/085 b/tests/qemu-iotests/085
index c53e97f..b97adcd 100755
--- a/tests/qemu-iotests/085
+++ b/tests/qemu-iotests/085
@@ -45,7 +45,7 @@ _cleanup()
rm -f "${TEST_DIR}/${i}-${snapshot_virt0}"
rm -f "${TEST_DIR}/${i}-${snapshot_virt1}"
done
- rm -f "${TEST_IMG}.1" "${TEST_IMG}.2"
+ rm -f "${TEST_IMG}" "${TEST_IMG}.1" "${TEST_IMG}.2" "${TEST_IMG}.base"
}
trap "_cleanup; exit \$status" 0 1 2 3 15
@@ -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,10 @@ echo === Invalid command - snapshot node has a backing image ===
echo
SNAPSHOTS=$((${SNAPSHOTS}+1))
-add_snapshot_image ${SNAPSHOTS} true
+
+TEST_IMG="$TEST_IMG.base" _make_test_img "$size"
+_make_test_img -b "${TEST_IMG}.base" "$size"
+do_blockdev_add ${SNAPSHOTS} "" "${TEST_IMG}"
blockdev_snapshot ${SNAPSHOTS} error
echo