]> Git Repo - qemu.git/blob - tests/qemu-iotests/087
block: Catch duplicate IDs in bdrv_new()
[qemu.git] / tests / qemu-iotests / 087
1 #!/bin/bash
2 #
3 # Test unsupported blockdev-add cases
4 #
5 # Copyright (C) 2014 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 [email protected]
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 here=`pwd`
28 tmp=/tmp/$$
29 status=1        # failure is the default!
30
31 # get standard environment, filters and checks
32 . ./common.rc
33 . ./common.filter
34
35 _supported_fmt qcow2
36 _supported_proto file
37 _supported_os Linux
38
39 function do_run_qemu()
40 {
41     echo Testing: "$@"
42     $QEMU -nographic -qmp stdio -serial none "$@"
43     echo
44 }
45
46 function run_qemu()
47 {
48     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
49 }
50
51 size=128M
52
53 _make_test_img $size
54
55 echo
56 echo === Missing ID ===
57 echo
58
59 run_qemu <<EOF
60 { "execute": "qmp_capabilities" }
61 { "execute": "blockdev-add",
62   "arguments": {
63       "options": {
64         "driver": "$IMGFMT",
65         "file": {
66             "driver": "file",
67             "filename": "$TEST_IMG"
68         }
69       }
70     }
71   }
72 { "execute": "quit" }
73 EOF
74
75 echo
76 echo === Duplicate ID ===
77 echo
78
79 run_qemu <<EOF
80 { "execute": "qmp_capabilities" }
81 { "execute": "blockdev-add",
82   "arguments": {
83       "options": {
84         "driver": "$IMGFMT",
85         "id": "disk",
86         "file": {
87             "driver": "file",
88             "filename": "$TEST_IMG"
89         }
90       }
91     }
92   }
93 { "execute": "blockdev-add",
94   "arguments": {
95       "options": {
96         "driver": "$IMGFMT",
97         "id": "disk",
98         "file": {
99             "driver": "file",
100             "filename": "$TEST_IMG"
101         }
102       }
103     }
104   }
105 { "execute": "quit" }
106 EOF
107
108 echo
109 echo === aio=native without O_DIRECT ===
110 echo
111
112 run_qemu <<EOF
113 { "execute": "qmp_capabilities" }
114 { "execute": "blockdev-add",
115   "arguments": {
116       "options": {
117         "driver": "$IMGFMT",
118         "id": "disk",
119         "aio": "native",
120         "file": {
121             "driver": "file",
122             "filename": "$TEST_IMG"
123         }
124       }
125     }
126   }
127 { "execute": "quit" }
128 EOF
129
130 echo
131 echo === Encrypted image ===
132 echo
133
134 _make_test_img -o encryption=on $size
135 run_qemu -S <<EOF
136 { "execute": "qmp_capabilities" }
137 { "execute": "blockdev-add",
138   "arguments": {
139       "options": {
140         "driver": "$IMGFMT",
141         "id": "disk",
142         "file": {
143             "driver": "file",
144             "filename": "$TEST_IMG"
145         }
146       }
147     }
148   }
149 { "execute": "quit" }
150 EOF
151
152 run_qemu <<EOF
153 { "execute": "qmp_capabilities" }
154 { "execute": "blockdev-add",
155   "arguments": {
156       "options": {
157         "driver": "$IMGFMT",
158         "id": "disk",
159         "file": {
160             "driver": "file",
161             "filename": "$TEST_IMG"
162         }
163       }
164     }
165   }
166 { "execute": "quit" }
167 EOF
168
169 # success, all done
170 echo "*** done"
171 rm -f $seq.full
172 status=0
This page took 0.036087 seconds and 4 git commands to generate.