]>
Commit | Line | Data |
---|---|---|
a6f230c8 AG |
1 | #!/bin/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 | # get standard environment, filters and checks | |
31 | . ./common.rc | |
32 | . ./common.filter | |
33 | ||
34 | _supported_fmt generic | |
35 | _supported_proto generic | |
36 | _supported_os Linux | |
37 | ||
38 | do_run_qemu() | |
39 | { | |
40 | echo Testing: "$@" | |
41 | $QEMU -nographic -qmp stdio -serial none "$@" | |
42 | echo | |
43 | } | |
44 | ||
45 | # Remove QMP events from (pretty-printed) output. Doesn't handle | |
46 | # nested dicts correctly, but we don't get any of those in this test. | |
47 | _filter_qmp_events() | |
48 | { | |
49 | tr '\n' '\t' | sed -e \ | |
50 | 's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \ | |
51 | | tr '\t' '\n' | |
52 | } | |
53 | ||
54 | run_qemu() | |
55 | { | |
56 | do_run_qemu "$@" 2>&1 | _filter_qmp | _filter_qmp_events | |
57 | } | |
58 | ||
59 | case "$QEMU_DEFAULT_MACHINE" in | |
60 | s390-ccw-virtio) | |
61 | virtio_scsi=virtio-scsi-ccw | |
62 | ;; | |
63 | *) | |
64 | virtio_scsi=virtio-scsi-pci | |
65 | ;; | |
66 | esac | |
67 | ||
68 | echo | |
69 | echo === Unplug a SCSI disk and then plug it again === | |
70 | echo | |
71 | ||
72 | run_qemu <<EOF | |
73 | { "execute": "qmp_capabilities" } | |
74 | { "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0"}} | |
75 | { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}} | |
76 | { "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}} | |
77 | { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}} | |
78 | { "execute": "device_del", "arguments": {"id": "scsi-hd0"}} | |
79 | { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}} | |
80 | { "execute": "device_del", "arguments": {"id": "scsi-hd0"}} | |
81 | { "execute": "device_del", "arguments": {"id": "scsi0"}} | |
82 | { "execute": "blockdev-del", "arguments": {"node-name": "hd0"}} | |
83 | { "execute": "quit"} | |
84 | EOF | |
85 | ||
3ff35ba3 AG |
86 | echo |
87 | echo === Attach two SCSI disks using the same block device and the same iothread === | |
88 | echo | |
89 | ||
90 | run_qemu <<EOF | |
91 | { "execute": "qmp_capabilities" } | |
92 | { "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true}} | |
93 | { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}} | |
94 | { "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}} | |
95 | { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}} | |
96 | { "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0"}} | |
97 | { "execute": "device_del", "arguments": {"id": "scsi-hd0"}} | |
98 | { "execute": "device_del", "arguments": {"id": "scsi-hd1"}} | |
99 | { "execute": "device_del", "arguments": {"id": "scsi0"}} | |
100 | { "execute": "blockdev-del", "arguments": {"node-name": "hd0"}} | |
101 | { "execute": "quit"} | |
102 | EOF | |
103 | ||
eb97813f AG |
104 | echo |
105 | echo === Attach two SCSI disks using the same block device but different iothreads === | |
106 | echo | |
107 | ||
108 | run_qemu <<EOF | |
109 | { "execute": "qmp_capabilities" } | |
110 | { "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true}} | |
111 | { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}} | |
112 | { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread1"}} | |
113 | { "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}} | |
114 | { "execute": "device_add", "arguments": {"id": "scsi1", "driver": "${virtio_scsi}", "iothread": "iothread1"}} | |
115 | { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}} | |
116 | { "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}} | |
117 | { "execute": "device_del", "arguments": {"id": "scsi-hd0"}} | |
118 | { "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}} | |
119 | { "execute": "device_del", "arguments": {"id": "scsi-hd1"}} | |
120 | { "execute": "device_del", "arguments": {"id": "scsi0"}} | |
121 | { "execute": "device_del", "arguments": {"id": "scsi1"}} | |
122 | { "execute": "blockdev-del", "arguments": {"node-name": "hd0"}} | |
123 | { "execute": "quit"} | |
124 | EOF | |
125 | ||
a6f230c8 AG |
126 | # success, all done |
127 | echo "*** done" | |
128 | rm -f $seq.full | |
129 | status=0 |