block: auto-generated node-names
[qemu/ar7.git] / tests / qemu-iotests / 067
blob3788534d67ad5d5403e2b3deb0faf8c99cd708ef
1 #!/bin/bash
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/>.
21 # creator
22 owner=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 here=`pwd`
28 tmp=/tmp/$$
29 status=1 # failure is the default!
31 # get standard environment, filters and checks
32 . ./common.rc
33 . ./common.filter
35 _supported_fmt qcow2
36 _supported_proto file
37 _supported_os Linux
38 # Because anything other than 16 would change the output of query-block
39 _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
41 function do_run_qemu()
43 echo Testing: "$@"
44 $QEMU -nographic -qmp-pretty stdio -serial none "$@"
45 echo
48 function run_qemu()
50 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu \
51 | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g' \
52 | _filter_generated_node_ids
55 size=128M
57 _make_test_img $size
59 echo
60 echo === -drive/-device and device_del ===
61 echo
63 run_qemu -drive file=$TEST_IMG,format=$IMGFMT,if=none,id=disk -device virtio-blk,drive=disk,id=virtio0 <<EOF
64 { "execute": "qmp_capabilities" }
65 { "execute": "query-block" }
66 { "execute": "device_del", "arguments": { "id": "virtio0" } }
67 { "execute": "system_reset" }
68 { "execute": "query-block" }
69 { "execute": "quit" }
70 EOF
72 echo
73 echo === -drive/device_add and device_del ===
74 echo
76 run_qemu -drive file=$TEST_IMG,format=$IMGFMT,if=none,id=disk <<EOF
77 { "execute": "qmp_capabilities" }
78 { "execute": "query-block" }
79 { "execute": "device_add",
80 "arguments": { "driver": "virtio-blk", "drive": "disk",
81 "id": "virtio0" } }
82 { "execute": "device_del", "arguments": { "id": "virtio0" } }
83 { "execute": "system_reset" }
84 { "execute": "query-block" }
85 { "execute": "quit" }
86 EOF
88 echo
89 echo === drive_add/device_add and device_del ===
90 echo
92 run_qemu <<EOF
93 { "execute": "qmp_capabilities" }
94 { "execute": "human-monitor-command",
95 "arguments": { "command-line": "drive_add 0 file=$TEST_IMG,format=$IMGFMT,if=none,id=disk" } }
96 { "execute": "query-block" }
97 { "execute": "device_add",
98 "arguments": { "driver": "virtio-blk", "drive": "disk",
99 "id": "virtio0" } }
100 { "execute": "device_del", "arguments": { "id": "virtio0" } }
101 { "execute": "system_reset" }
102 { "execute": "query-block" }
103 { "execute": "quit" }
106 echo
107 echo === blockdev_add/device_add and device_del ===
108 echo
110 run_qemu <<EOF
111 { "execute": "qmp_capabilities" }
112 { "execute": "blockdev-add",
113 "arguments": {
114 "options": {
115 "driver": "$IMGFMT",
116 "id": "disk",
117 "file": {
118 "driver": "file",
119 "filename": "$TEST_IMG"
124 { "execute": "query-block" }
125 { "execute": "device_add",
126 "arguments": { "driver": "virtio-blk", "drive": "disk",
127 "id": "virtio0" } }
128 { "execute": "device_del", "arguments": { "id": "virtio0" } }
129 { "execute": "system_reset" }
130 { "execute": "query-block" }
131 { "execute": "quit" }
134 # success, all done
135 echo "*** done"
136 rm -f $seq.full
137 status=0