block: qemu-iotests - update 085 to use common.qemu
The new functionality of common.qemu implements the QEMU control and communication functionality that was originally in test 085. This removes that now-duplicate functionality, and uses the common.qemu functions. The QEMU commandline changes slightly due to this; in addition to monitor and qmp i/o options, the new QEMU commandline from inside common.qemu now introduces -machine accel=qtest. Reviewed-by: Benoit Canet <benoit@irqsave.net> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
e940bc13ee
commit
e86e869770
@ -30,10 +30,6 @@ echo "QA output created by $seq"
|
|||||||
|
|
||||||
here=`pwd`
|
here=`pwd`
|
||||||
status=1 # failure is the default!
|
status=1 # failure is the default!
|
||||||
qemu_pid=
|
|
||||||
|
|
||||||
QMP_IN="${TEST_DIR}/qmp-in-$$"
|
|
||||||
QMP_OUT="${TEST_DIR}/qmp-out-$$"
|
|
||||||
|
|
||||||
snapshot_virt0="snapshot-v0.qcow2"
|
snapshot_virt0="snapshot-v0.qcow2"
|
||||||
snapshot_virt1="snapshot-v1.qcow2"
|
snapshot_virt1="snapshot-v1.qcow2"
|
||||||
@ -42,10 +38,7 @@ MAX_SNAPSHOTS=10
|
|||||||
|
|
||||||
_cleanup()
|
_cleanup()
|
||||||
{
|
{
|
||||||
kill -KILL ${qemu_pid}
|
_cleanup_qemu
|
||||||
wait ${qemu_pid} 2>/dev/null # silent kill
|
|
||||||
|
|
||||||
rm -f "${QMP_IN}" "${QMP_OUT}"
|
|
||||||
for i in $(seq 1 ${MAX_SNAPSHOTS})
|
for i in $(seq 1 ${MAX_SNAPSHOTS})
|
||||||
do
|
do
|
||||||
rm -f "${TEST_DIR}/${i}-${snapshot_virt0}"
|
rm -f "${TEST_DIR}/${i}-${snapshot_virt0}"
|
||||||
@ -59,43 +52,12 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
|
|||||||
# get standard environment, filters and checks
|
# get standard environment, filters and checks
|
||||||
. ./common.rc
|
. ./common.rc
|
||||||
. ./common.filter
|
. ./common.filter
|
||||||
|
. ./common.qemu
|
||||||
|
|
||||||
_supported_fmt qcow2
|
_supported_fmt qcow2
|
||||||
_supported_proto file
|
_supported_proto file
|
||||||
_supported_os Linux
|
_supported_os Linux
|
||||||
|
|
||||||
# Wait for expected QMP response from QEMU. Will time out
|
|
||||||
# after 10 seconds, which counts as failure.
|
|
||||||
#
|
|
||||||
# $1 is the string to expect
|
|
||||||
#
|
|
||||||
# If $silent is set to anything but an empty string, then
|
|
||||||
# response is not echoed out.
|
|
||||||
function timed_wait_for()
|
|
||||||
{
|
|
||||||
while read -t 10 resp <&5
|
|
||||||
do
|
|
||||||
if [ "${silent}" == "" ]; then
|
|
||||||
echo "${resp}" | _filter_testdir | _filter_qemu
|
|
||||||
fi
|
|
||||||
grep -q "${1}" < <(echo ${resp})
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo "Timeout waiting for ${1}"
|
|
||||||
exit 1 # Timeout means the test failed
|
|
||||||
}
|
|
||||||
|
|
||||||
# Sends QMP command to QEMU, and waits for the expected response
|
|
||||||
#
|
|
||||||
# ${1}: String of the QMP command to send
|
|
||||||
# ${2}: String that the QEMU response should contain
|
|
||||||
function send_qmp_cmd()
|
|
||||||
{
|
|
||||||
echo "${1}" >&6
|
|
||||||
timed_wait_for "${2}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ${1}: unique identifier for the snapshot filename
|
# ${1}: unique identifier for the snapshot filename
|
||||||
function create_single_snapshot()
|
function create_single_snapshot()
|
||||||
@ -104,7 +66,7 @@ function create_single_snapshot()
|
|||||||
'arguments': { 'device': 'virtio0',
|
'arguments': { 'device': 'virtio0',
|
||||||
'snapshot-file':'"${TEST_DIR}/${1}-${snapshot_virt0}"',
|
'snapshot-file':'"${TEST_DIR}/${1}-${snapshot_virt0}"',
|
||||||
'format': 'qcow2' } }"
|
'format': 'qcow2' } }"
|
||||||
send_qmp_cmd "${cmd}" "return"
|
_send_qemu_cmd $h "${cmd}" "return"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ${1}: unique identifier for the snapshot filename
|
# ${1}: unique identifier for the snapshot filename
|
||||||
@ -120,14 +82,11 @@ function create_group_snapshot()
|
|||||||
'snapshot-file': '"${TEST_DIR}/${1}-${snapshot_virt1}"' } } ]
|
'snapshot-file': '"${TEST_DIR}/${1}-${snapshot_virt1}"' } } ]
|
||||||
} }"
|
} }"
|
||||||
|
|
||||||
send_qmp_cmd "${cmd}" "return"
|
_send_qemu_cmd $h "${cmd}" "return"
|
||||||
}
|
}
|
||||||
|
|
||||||
size=128M
|
size=128M
|
||||||
|
|
||||||
mkfifo "${QMP_IN}"
|
|
||||||
mkfifo "${QMP_OUT}"
|
|
||||||
|
|
||||||
_make_test_img $size
|
_make_test_img $size
|
||||||
mv "${TEST_IMG}" "${TEST_IMG}.orig"
|
mv "${TEST_IMG}" "${TEST_IMG}.orig"
|
||||||
_make_test_img $size
|
_make_test_img $size
|
||||||
@ -136,23 +95,15 @@ echo
|
|||||||
echo === Running QEMU ===
|
echo === Running QEMU ===
|
||||||
echo
|
echo
|
||||||
|
|
||||||
"${QEMU}" -nographic -monitor none -serial none -qmp stdio\
|
qemu_comm_method="qmp"
|
||||||
-drive file="${TEST_IMG}.orig",if=virtio\
|
_launch_qemu -drive file="${TEST_IMG}.orig",if=virtio -drive file="${TEST_IMG}",if=virtio
|
||||||
-drive file="${TEST_IMG}",if=virtio 2>&1 >"${QMP_OUT}" <"${QMP_IN}"&
|
h=$QEMU_HANDLE
|
||||||
qemu_pid=$!
|
|
||||||
|
|
||||||
# redirect fifos to file descriptors, to keep from blocking
|
|
||||||
exec 5<"${QMP_OUT}"
|
|
||||||
exec 6>"${QMP_IN}"
|
|
||||||
|
|
||||||
# Don't print response, since it has version information in it
|
|
||||||
silent=yes timed_wait_for "capabilities"
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo === Sending capabilities ===
|
echo === Sending capabilities ===
|
||||||
echo
|
echo
|
||||||
|
|
||||||
send_qmp_cmd "{ 'execute': 'qmp_capabilities' }" "return"
|
_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo === Create a single snapshot on virtio0 ===
|
echo === Create a single snapshot on virtio0 ===
|
||||||
@ -165,16 +116,16 @@ echo
|
|||||||
echo === Invalid command - missing device and nodename ===
|
echo === Invalid command - missing device and nodename ===
|
||||||
echo
|
echo
|
||||||
|
|
||||||
send_qmp_cmd "{ 'execute': 'blockdev-snapshot-sync',
|
_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync',
|
||||||
'arguments': { 'snapshot-file':'"${TEST_DIR}"/1-${snapshot_virt0}',
|
'arguments': { 'snapshot-file':'"${TEST_DIR}/1-${snapshot_virt0}"',
|
||||||
'format': 'qcow2' } }" "error"
|
'format': 'qcow2' } }" "error"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo === Invalid command - missing snapshot-file ===
|
echo === Invalid command - missing snapshot-file ===
|
||||||
echo
|
echo
|
||||||
|
|
||||||
send_qmp_cmd "{ 'execute': 'blockdev-snapshot-sync',
|
_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync',
|
||||||
'arguments': { 'device': 'virtio0',
|
'arguments': { 'device': 'virtio0',
|
||||||
'format': 'qcow2' } }" "error"
|
'format': 'qcow2' } }" "error"
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user