]> git.proxmox.com Git - mirror_qemu.git/blob - tests/qemu-iotests/067
i386: Update new x86_apicid parsing rules with die_offset support
[mirror_qemu.git] / tests / qemu-iotests / 067
1 #!/usr/bin/env bash
2 #
3 # Test automatic deletion of BDSes created by -drive/drive_add
4 #
5 # Copyright (C) 2013 Red Hat, Inc.
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 # creator
22 owner=kwolf@redhat.com
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 status=1 # failure is the default!
28
29 # get standard environment, filters and checks
30 . ./common.rc
31 . ./common.filter
32
33 _supported_fmt qcow2
34 _supported_proto file
35 # Because anything other than 16 would change the output of query-block
36 _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)'
37
38 do_run_qemu()
39 {
40 echo Testing: "$@"
41 $QEMU -nographic -qmp-pretty 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_testdir | _filter_qmp | _filter_qemu \
57 | _filter_actual_image_size \
58 | _filter_generated_node_ids | _filter_qmp_events \
59 | _filter_img_info
60 }
61
62 size=128M
63
64 _make_test_img $size
65
66 echo
67 echo === -drive/-device and device_del ===
68 echo
69
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" }
76 { "execute": "quit" }
77 EOF
78
79 echo
80 echo === -drive/device_add and device_del ===
81 echo
82
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",
88 "id": "virtio0" } }
89 { "execute": "device_del", "arguments": { "id": "virtio0" } }
90 { "execute": "system_reset" }
91 { "execute": "query-block" }
92 { "execute": "quit" }
93 EOF
94
95 echo
96 echo === drive_add/device_add and device_del ===
97 echo
98
99 run_qemu <<EOF
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",
106 "id": "virtio0" } }
107 { "execute": "device_del", "arguments": { "id": "virtio0" } }
108 { "execute": "system_reset" }
109 { "execute": "query-block" }
110 { "execute": "quit" }
111 EOF
112
113 echo
114 echo === blockdev_add/device_add and device_del ===
115 echo
116
117 run_qemu <<EOF
118 { "execute": "qmp_capabilities" }
119 { "execute": "blockdev-add",
120 "arguments": {
121 "driver": "$IMGFMT",
122 "node-name": "disk",
123 "file": {
124 "driver": "file",
125 "filename": "$TEST_IMG"
126 }
127 }
128 }
129 { "execute": "query-named-block-nodes" }
130 { "execute": "device_add",
131 "arguments": { "driver": "virtio-blk", "drive": "disk",
132 "id": "virtio0" } }
133 { "execute": "device_del", "arguments": { "id": "virtio0" } }
134 { "execute": "system_reset" }
135 { "execute": "query-named-block-nodes" }
136 { "execute": "quit" }
137 EOF
138
139 echo
140 echo === Empty drive with -device and device_del ===
141 echo
142
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" }
150 EOF
151
152 # success, all done
153 echo "*** done"
154 rm -f $seq.full
155 status=0