xref: /openbmc/qemu/tests/qemu-iotests/087 (revision 52f91c37)
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
22owner=kwolf@redhat.com
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
27here=`pwd`
28tmp=/tmp/$$
29status=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
39function do_run_qemu()
40{
41    echo Testing: "$@"
42    $QEMU -nographic -qmp stdio -serial none "$@"
43    echo
44}
45
46function 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
51size=128M
52
53_make_test_img $size
54
55echo
56echo === Missing ID ===
57echo
58
59run_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" }
73EOF
74
75echo
76echo === Duplicate ID ===
77echo
78
79run_qemu <<EOF
80{ "execute": "qmp_capabilities" }
81{ "execute": "blockdev-add",
82  "arguments": {
83      "options": {
84        "driver": "$IMGFMT",
85        "id": "disk",
86        "node-name": "test-node",
87        "file": {
88            "driver": "file",
89            "filename": "$TEST_IMG"
90        }
91      }
92    }
93  }
94{ "execute": "blockdev-add",
95  "arguments": {
96      "options": {
97        "driver": "$IMGFMT",
98        "id": "disk",
99        "file": {
100            "driver": "file",
101            "filename": "$TEST_IMG"
102        }
103      }
104    }
105  }
106{ "execute": "blockdev-add",
107  "arguments": {
108      "options": {
109        "driver": "$IMGFMT",
110        "id": "test-node",
111        "file": {
112            "driver": "file",
113            "filename": "$TEST_IMG"
114        }
115      }
116    }
117  }
118{ "execute": "blockdev-add",
119  "arguments": {
120      "options": {
121        "driver": "$IMGFMT",
122        "id": "disk2",
123        "node-name": "disk",
124        "file": {
125            "driver": "file",
126            "filename": "$TEST_IMG"
127        }
128      }
129    }
130  }
131{ "execute": "blockdev-add",
132  "arguments": {
133      "options": {
134        "driver": "$IMGFMT",
135        "id": "disk2",
136        "node-name": "test-node",
137        "file": {
138            "driver": "file",
139            "filename": "$TEST_IMG"
140        }
141      }
142    }
143  }
144{ "execute": "blockdev-add",
145  "arguments": {
146      "options": {
147        "driver": "$IMGFMT",
148        "id": "disk3",
149        "node-name": "disk3",
150        "file": {
151            "driver": "file",
152            "filename": "$TEST_IMG"
153        }
154      }
155    }
156  }
157{ "execute": "quit" }
158EOF
159
160echo
161echo === aio=native without O_DIRECT ===
162echo
163
164run_qemu <<EOF
165{ "execute": "qmp_capabilities" }
166{ "execute": "blockdev-add",
167  "arguments": {
168      "options": {
169        "driver": "$IMGFMT",
170        "id": "disk",
171        "aio": "native",
172        "file": {
173            "driver": "file",
174            "filename": "$TEST_IMG"
175        }
176      }
177    }
178  }
179{ "execute": "quit" }
180EOF
181
182echo
183echo === Encrypted image ===
184echo
185
186_make_test_img -o encryption=on $size
187run_qemu -S <<EOF
188{ "execute": "qmp_capabilities" }
189{ "execute": "blockdev-add",
190  "arguments": {
191      "options": {
192        "driver": "$IMGFMT",
193        "id": "disk",
194        "file": {
195            "driver": "file",
196            "filename": "$TEST_IMG"
197        }
198      }
199    }
200  }
201{ "execute": "quit" }
202EOF
203
204run_qemu <<EOF
205{ "execute": "qmp_capabilities" }
206{ "execute": "blockdev-add",
207  "arguments": {
208      "options": {
209        "driver": "$IMGFMT",
210        "id": "disk",
211        "file": {
212            "driver": "file",
213            "filename": "$TEST_IMG"
214        }
215      }
216    }
217  }
218{ "execute": "quit" }
219EOF
220
221# success, all done
222echo "*** done"
223rm -f $seq.full
224status=0
225