multifd: Add zstd compression multifd support
[qemu/kevin.git] / tests / qemu-iotests / 240
blob8b4337b58dd05cccab3c47b1706256e7e794dad6
1 #!/usr/bin/env bash
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/>.
22 # creator
23 owner=berto@igalia.com
25 seq=`basename $0`
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
30 _cleanup()
32 rm -f "$SOCK_DIR/nbd"
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
40 _supported_fmt generic
41 _supported_proto generic
43 do_run_qemu()
45 echo Testing: "$@"
46 $QEMU -nographic -qmp stdio -serial none "$@"
47 echo
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()
54 tr '\n' '\t' | sed -e \
55 's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \
56 | tr '\t' '\n'
59 run_qemu()
61 do_run_qemu "$@" 2>&1 | _filter_qmp | _filter_qmp_events
64 case "$QEMU_DEFAULT_MACHINE" in
65 s390-ccw-virtio)
66 virtio_scsi=virtio-scsi-ccw
69 virtio_scsi=virtio-scsi-pci
71 esac
73 echo
74 echo === Unplug a SCSI disk and then plug it again ===
75 echo
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
91 echo
92 echo === Attach two SCSI disks using the same block device and the same iothread ===
93 echo
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"}
109 echo
110 echo === Attach two SCSI disks using the same block device but different iothreads ===
111 echo
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"}
131 echo
132 echo === Attach a SCSI disks using the same block device as a NBD server ===
133 echo
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"}
146 # success, all done
147 echo "*** done"
148 rm -f $seq.full
149 status=0