3 # Test hot plugging and unplugging with iothreads
5 # Copyright (C) 2019 Igalia, S.L.
6 # Author: Alberto Garcia <berto@igalia.com>
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/>.
23 owner
=berto@igalia.com
26 echo "QA output created by $seq"
28 status
=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
40 _supported_fmt generic
41 _supported_proto generic
46 $QEMU -nographic -qmp stdio
-serial none
"$@"
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.
54 tr '\n' '\t' |
sed -e \
55 's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \
61 do_run_qemu
"$@" 2>&1 | _filter_qmp | _filter_qmp_events
64 case "$QEMU_DEFAULT_MACHINE" in
66 virtio_scsi
=virtio-scsi-ccw
69 virtio_scsi
=virtio-scsi-pci
74 echo === Unplug a SCSI disk and
then plug it again
===
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"}}
92 echo === Attach two SCSI disks using the same block device and the same iothread
===
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"}}
110 echo === Attach two SCSI disks using the same block device but different iothreads
===
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"}}
132 echo === Attach a SCSI disks using the same block device as a NBD server
===
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"}}