3 # Test automatic deletion of BDSes created by -drive/drive_add
5 # Copyright (C) 2013 Red Hat, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 owner
=kwolf@redhat.com
25 echo "QA output created by $seq"
27 status
=1 # failure is the default!
29 # get standard environment, filters and checks
35 # Because anything other than 16 would change the output of query-block
36 _unsupported_imgopts
'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
41 $QEMU -nographic -qmp-pretty stdio
-serial none
"$@"
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.
49 tr '\n' '\t' |
sed -e \
50 's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \
56 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu \
57 | _filter_actual_image_size \
58 | _filter_generated_node_ids | _filter_qmp_events \
67 echo === -drive/-device and device_del
===
70 run_qemu
-drive file=$TEST_IMG,format
=$IMGFMT,if=none
,id
=disk
-device virtio-blk
,drive
=disk
,id
=virtio0
<<EOF
71 { "execute": "qmp_capabilities" }
72 { "execute": "query-block" }
73 { "execute": "device_del", "arguments": { "id": "virtio0" } }
74 { "execute": "system_reset" }
75 { "execute": "query-block" }
80 echo === -drive/device_add and device_del
===
83 run_qemu
-drive file=$TEST_IMG,format
=$IMGFMT,if=none
,id
=disk
<<EOF
84 { "execute": "qmp_capabilities" }
85 { "execute": "query-block" }
86 { "execute": "device_add",
87 "arguments": { "driver": "virtio-blk", "drive": "disk",
89 { "execute": "device_del", "arguments": { "id": "virtio0" } }
90 { "execute": "system_reset" }
91 { "execute": "query-block" }
96 echo === drive_add
/device_add and device_del
===
100 { "execute": "qmp_capabilities" }
101 { "execute": "human-monitor-command",
102 "arguments": { "command-line": "drive_add 0 file=$TEST_IMG,format=$IMGFMT,if=none,id=disk" } }
103 { "execute": "query-block" }
104 { "execute": "device_add",
105 "arguments": { "driver": "virtio-blk", "drive": "disk",
107 { "execute": "device_del", "arguments": { "id": "virtio0" } }
108 { "execute": "system_reset" }
109 { "execute": "query-block" }
110 { "execute": "quit" }
114 echo === blockdev_add
/device_add and device_del
===
118 { "execute": "qmp_capabilities" }
119 { "execute": "blockdev-add",
125 "filename": "$TEST_IMG"
129 { "execute": "query-named-block-nodes" }
130 { "execute": "device_add",
131 "arguments": { "driver": "virtio-blk", "drive": "disk",
133 { "execute": "device_del", "arguments": { "id": "virtio0" } }
134 { "execute": "system_reset" }
135 { "execute": "query-named-block-nodes" }
136 { "execute": "quit" }
140 echo === Empty drive with
-device and device_del
===
143 run_qemu
-device virtio-scsi
-device scsi-cd
,id
=cd0
<<EOF
144 { "execute": "qmp_capabilities" }
145 { "execute": "query-block" }
146 { "execute": "device_del", "arguments": { "id": "cd0" } }
147 { "execute": "system_reset" }
148 { "execute": "query-block" }
149 { "execute": "quit" }