From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [PATCH 2/2] iotests/qsd-jobs: Use common.qemu for the QSD
Date: Thu, 1 Apr 2021 15:28:15 +0200 [thread overview]
Message-ID: <20210401132815.139575-3-mreitz@redhat.com> (raw)
In-Reply-To: <20210401132815.139575-1-mreitz@redhat.com>
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
next prev parent reply other threads:[~2021-04-01 13:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 13:28 [PATCH 0/2] iotests/qsd-jobs: Use common.qemu for the QSD Max Reitz
2021-04-01 13:28 ` [PATCH 1/2] iotests/common.qemu: Allow using " Max Reitz
2021-04-01 13:28 ` Max Reitz [this message]
2021-04-01 14:44 ` [PATCH 2/2] iotests/qsd-jobs: Use common.qemu for " Vladimir Sementsov-Ogievskiy
2021-04-01 15:33 ` Max Reitz
2021-04-26 10:06 ` [PATCH 0/2] " Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210401132815.139575-3-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).