[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] iotests/qsd-jobs: Use common.qemu for the QSD
From: |
Max Reitz |
Subject: |
[PATCH 2/2] iotests/qsd-jobs: Use common.qemu for the QSD |
Date: |
Thu, 1 Apr 2021 15:28:15 +0200 |
Using common.qemu allows us to wait for specific replies, so we can for
example wait for events. This allows starting the active commit job and
then wait for it to be ready before quitting the QSD, so we the output
is always the same.
(Strictly speaking, this is only necessary for the first test in
qsd-jobs, but we might as well make the second one use common.qemu's
infrastructure, too.)
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
tests/qemu-iotests/tests/qsd-jobs | 55 ++++++++++++++++++++-------
tests/qemu-iotests/tests/qsd-jobs.out | 10 ++++-
2 files changed, 49 insertions(+), 16 deletions(-)
diff --git a/tests/qemu-iotests/tests/qsd-jobs
b/tests/qemu-iotests/tests/qsd-jobs
index 972b6b3898..af7f886f15 100755
--- a/tests/qemu-iotests/tests/qsd-jobs
+++ b/tests/qemu-iotests/tests/qsd-jobs
@@ -38,6 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
cd ..
. ./common.rc
. ./common.filter
+. ./common.qemu
_supported_fmt qcow2
_supported_proto generic
@@ -52,32 +53,58 @@ echo "=== Job still present at shutdown ==="
echo
# Just make sure that this doesn't crash
-$QSD --chardev stdio,id=stdio --monitor chardev=stdio \
+qsd=y _launch_qemu \
--blockdev node-name=file0,driver=file,filename="$TEST_IMG" \
- --blockdev node-name=fmt0,driver=qcow2,file=file0 <<EOF | _filter_qmp
-{"execute":"qmp_capabilities"}
-{"execute": "block-commit", "arguments": {"device": "fmt0", "job-id": "job0"}}
-{"execute": "quit"}
-EOF
+ --blockdev node-name=fmt0,driver=qcow2,file=file0
+
+_send_qemu_cmd \
+ $QEMU_HANDLE \
+ '{"execute":"qmp_capabilities"}' \
+ 'return'
+
+_send_qemu_cmd \
+ $QEMU_HANDLE \
+ '{"execute": "block-commit",
+ "arguments": {"device": "fmt0", "job-id": "job0"}}' \
+ 'BLOCK_JOB_READY'
+
+_send_qemu_cmd \
+ $QEMU_HANDLE \
+ '{"execute": "quit"}' \
+ 'return'
+
+wait=y _cleanup_qemu
echo
echo "=== Streaming can't get permission on base node ==="
echo
# Just make sure that this doesn't crash
-$QSD --chardev stdio,id=stdio --monitor chardev=stdio \
+qsd=y _launch_qemu \
--blockdev node-name=file_base,driver=file,filename="$TEST_IMG.base" \
--blockdev node-name=fmt_base,driver=qcow2,file=file_base \
--blockdev node-name=file_overlay,driver=file,filename="$TEST_IMG" \
--blockdev
node-name=fmt_overlay,driver=qcow2,file=file_overlay,backing=fmt_base \
--nbd-server addr.type=unix,addr.path="$SOCK_DIR/nbd.sock" \
- --export type=nbd,id=export1,node-name=fmt_base,writable=on,name=export1 \
- <<EOF | _filter_qmp
-{"execute": "qmp_capabilities"}
-{"execute": "block-stream",
- "arguments": {"device": "fmt_overlay", "job-id": "job0"}}
-{"execute": "quit"}
-EOF
+ --export type=nbd,id=export1,node-name=fmt_base,writable=on,name=export1
+
+_send_qemu_cmd \
+ $QEMU_HANDLE \
+ '{"execute": "qmp_capabilities"}' \
+ 'return'
+
+_send_qemu_cmd \
+ $QEMU_HANDLE \
+ '{"execute": "block-stream",
+ "arguments": {"device": "fmt_overlay", "job-id": "job0"}}' \
+ 'error'
+
+_send_qemu_cmd \
+ $QEMU_HANDLE \
+ '{"execute": "quit"}' \
+ 'return'
+
+wait=y _cleanup_qemu
# success, all done
echo "*** done"
diff --git a/tests/qemu-iotests/tests/qsd-jobs.out
b/tests/qemu-iotests/tests/qsd-jobs.out
index 05e1165e80..5a14668939 100644
--- a/tests/qemu-iotests/tests/qsd-jobs.out
+++ b/tests/qemu-iotests/tests/qsd-jobs.out
@@ -4,13 +4,16 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
backing_file=TEST_DIR/
=== Job still present at shutdown ===
-QMP_VERSION
+{"execute":"qmp_capabilities"}
{"return": {}}
+{"execute": "block-commit",
+ "arguments": {"device": "fmt0", "job-id": "job0"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "job0"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "speed":
0, "type": "commit"}}
+{"execute": "quit"}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"JOB_STATUS_CHANGE", "data": {"status": "standby", "id": "job0"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "job0"}}
@@ -22,11 +25,14 @@ QMP_VERSION
=== Streaming can't get permission on base node ===
-QMP_VERSION
+{"execute": "qmp_capabilities"}
{"return": {}}
+{"execute": "block-stream",
+ "arguments": {"device": "fmt_overlay", "job-id": "job0"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}}
{"error": {"class": "GenericError", "desc": "Conflicts with use by a block
device as 'root', which uses 'write' on fmt_base"}}
+{"execute": "quit"}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"BLOCK_EXPORT_DELETED", "data": {"id": "export1"}}
*** done
--
2.29.2