Merge remote-tracking branch 'qemu-project/master'
[qemu/ar7.git] / tests / qemu-iotests / tests / qsd-jobs
blob510bf0a9dcbf7aad1bd1e86536ee70a91a22d3a9
1 #!/usr/bin/env bash
2 # group: rw auto quick qsd
4 # Job tests related specifically to qemu-storage-daemon
6 # Copyright (C) 2021 Red Hat, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # creator
23 owner=kwolf@redhat.com
25 seq="$(basename $0)"
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 _cleanup()
32 _cleanup_test_img
33 rm -f "$SOCK_DIR/nbd.sock"
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
38 cd ..
39 . ./common.rc
40 . ./common.filter
42 _supported_fmt qcow2
43 _supported_proto generic
45 size=128M
47 TEST_IMG="$TEST_IMG.base" _make_test_img $size
48 _make_test_img -b "$TEST_IMG.base" -F $IMGFMT
50 echo
51 echo "=== Job still present at shutdown ==="
52 echo
54 # Just make sure that this doesn't crash
55 # (Filter job status and READY events, because their order may differ
56 # between runs, particularly around when 'quit' is issued)
57 $QSD --chardev stdio,id=stdio --monitor chardev=stdio \
58 --blockdev node-name=file0,driver=file,filename="$TEST_IMG" \
59 --blockdev node-name=fmt0,driver=qcow2,file=file0 <<EOF \
60 | _filter_qmp | grep -v JOB_STATUS_CHANGE | grep -v BLOCK_JOB_READY
61 {"execute":"qmp_capabilities"}
62 {"execute": "block-commit", "arguments": {"device": "fmt0", "job-id": "job0"}}
63 {"execute": "quit"}
64 EOF
66 echo
67 echo "=== Streaming can't get permission on base node ==="
68 echo
70 # Just make sure that this doesn't crash
71 $QSD --chardev stdio,id=stdio --monitor chardev=stdio \
72 --blockdev node-name=file_base,driver=file,filename="$TEST_IMG.base" \
73 --blockdev node-name=fmt_base,driver=qcow2,file=file_base \
74 --blockdev node-name=file_overlay,driver=file,filename="$TEST_IMG" \
75 --blockdev node-name=fmt_overlay,driver=qcow2,file=file_overlay,backing=fmt_base \
76 --nbd-server addr.type=unix,addr.path="$SOCK_DIR/nbd.sock" \
77 --export type=nbd,id=export1,node-name=fmt_base,writable=on,name=export1 \
78 <<EOF | _filter_qmp
79 {"execute": "qmp_capabilities"}
80 {"execute": "block-stream",
81 "arguments": {"device": "fmt_overlay", "job-id": "job0"}}
82 {"execute": "quit"}
83 EOF
85 # success, all done
86 echo "*** done"
87 rm -f $seq.full
88 status=0