xref: /openbmc/qemu/tests/qemu-iotests/087 (revision 23961870)
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 === aio=native without O_DIRECT ===
77echo
78
79run_qemu <<EOF
80{ "execute": "qmp_capabilities" }
81{ "execute": "blockdev-add",
82  "arguments": {
83      "options": {
84        "driver": "$IMGFMT",
85        "id": "disk",
86        "aio": "native",
87        "file": {
88            "driver": "file",
89            "filename": "$TEST_IMG"
90        }
91      }
92    }
93  }
94{ "execute": "quit" }
95EOF
96
97echo
98echo === Encrypted image ===
99echo
100
101_make_test_img -o encryption=on $size
102run_qemu <<EOF
103{ "execute": "qmp_capabilities" }
104{ "execute": "blockdev-add",
105  "arguments": {
106      "options": {
107        "driver": "$IMGFMT",
108        "id": "disk",
109        "file": {
110            "driver": "file",
111            "filename": "$TEST_IMG"
112        }
113      }
114    }
115  }
116{ "execute": "quit" }
117EOF
118
119# success, all done
120echo "*** done"
121rm -f $seq.full
122status=0
123