]> Git Repo - qemu.git/blob - tests/qemu-iotests/240
tests/docker: add docs FEATURE flag and use for test-misc
[qemu.git] / tests / qemu-iotests / 240
1 #!/usr/bin/env bash
2 #
3 # Test hot plugging and unplugging with iothreads
4 #
5 # Copyright (C) 2019 Igalia, S.L.
6 # Author: Alberto Garcia <[email protected]>
7 #
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.
12 #
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.
17 #
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/>.
20 #
21
22 # creator
23 [email protected]
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 status=1        # failure is the default!
29
30 _cleanup()
31 {
32     rm -f "$SOCK_DIR/nbd"
33 }
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
39
40 _supported_fmt generic
41 _supported_proto generic
42
43 do_run_qemu()
44 {
45     echo Testing: "$@"
46     $QEMU -nographic -qmp stdio -serial none "$@"
47     echo
48 }
49
50 # Remove QMP events from (pretty-printed) output. Doesn't handle
51 # nested dicts correctly, but we don't get any of those in this test.
52 _filter_qmp_events()
53 {
54     tr '\n' '\t' | sed -e \
55         's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \
56         | tr '\t' '\n'
57 }
58
59 run_qemu()
60 {
61     do_run_qemu "$@" 2>&1 | _filter_qmp | _filter_qmp_events
62 }
63
64 case "$QEMU_DEFAULT_MACHINE" in
65   s390-ccw-virtio)
66       virtio_scsi=virtio-scsi-ccw
67       ;;
68   *)
69       virtio_scsi=virtio-scsi-pci
70       ;;
71 esac
72
73 echo
74 echo === Unplug a SCSI disk and then plug it again ===
75 echo
76
77 run_qemu <<EOF
78 { "execute": "qmp_capabilities" }
79 { "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0"}}
80 { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
81 { "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
82 { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
83 { "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
84 { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
85 { "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
86 { "execute": "device_del", "arguments": {"id": "scsi0"}}
87 { "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
88 { "execute": "quit"}
89 EOF
90
91 echo
92 echo === Attach two SCSI disks using the same block device and the same iothread ===
93 echo
94
95 run_qemu <<EOF
96 { "execute": "qmp_capabilities" }
97 { "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
98 { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
99 { "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
100 { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
101 { "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0"}}
102 { "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
103 { "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
104 { "execute": "device_del", "arguments": {"id": "scsi0"}}
105 { "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
106 { "execute": "quit"}
107 EOF
108
109 echo
110 echo === Attach two SCSI disks using the same block device but different iothreads ===
111 echo
112
113 run_qemu <<EOF
114 { "execute": "qmp_capabilities" }
115 { "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
116 { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
117 { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread1"}}
118 { "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
119 { "execute": "device_add", "arguments": {"id": "scsi1", "driver": "${virtio_scsi}", "iothread": "iothread1"}}
120 { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
121 { "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
122 { "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
123 { "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
124 { "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
125 { "execute": "device_del", "arguments": {"id": "scsi0"}}
126 { "execute": "device_del", "arguments": {"id": "scsi1"}}
127 { "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
128 { "execute": "quit"}
129 EOF
130
131 echo
132 echo === Attach a SCSI disks using the same block device as a NBD server ===
133 echo
134
135 run_qemu <<EOF
136 { "execute": "qmp_capabilities" }
137 { "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
138 { "execute": "nbd-server-start", "arguments": {"addr":{"type":"unix","data":{"path":"$SOCK_DIR/nbd"}}}}
139 { "execute": "nbd-server-add", "arguments": {"device":"hd0"}}
140 { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
141 { "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
142 { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
143 { "execute": "quit"}
144 EOF
145
146 # success, all done
147 echo "*** done"
148 rm -f $seq.full
149 status=0
This page took 0.033086 seconds and 4 git commands to generate.