xref: /openbmc/qemu/tests/qemu-iotests/087 (revision c3adb58fe0b2db4942f5b2f5d19bc51a29b93a89)
1c75203c8SKevin Wolf#!/bin/bash
2c75203c8SKevin Wolf#
3c75203c8SKevin Wolf# Test unsupported blockdev-add cases
4c75203c8SKevin Wolf#
5c75203c8SKevin Wolf# Copyright (C) 2014 Red Hat, Inc.
6c75203c8SKevin Wolf#
7c75203c8SKevin Wolf# This program is free software; you can redistribute it and/or modify
8c75203c8SKevin Wolf# it under the terms of the GNU General Public License as published by
9c75203c8SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10c75203c8SKevin Wolf# (at your option) any later version.
11c75203c8SKevin Wolf#
12c75203c8SKevin Wolf# This program is distributed in the hope that it will be useful,
13c75203c8SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14c75203c8SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15c75203c8SKevin Wolf# GNU General Public License for more details.
16c75203c8SKevin Wolf#
17c75203c8SKevin Wolf# You should have received a copy of the GNU General Public License
18c75203c8SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19c75203c8SKevin Wolf#
20c75203c8SKevin Wolf
21c75203c8SKevin Wolf# creator
22c75203c8SKevin Wolfowner=kwolf@redhat.com
23c75203c8SKevin Wolf
24c75203c8SKevin Wolfseq=`basename $0`
25c75203c8SKevin Wolfecho "QA output created by $seq"
26c75203c8SKevin Wolf
27c75203c8SKevin Wolfhere=`pwd`
28c75203c8SKevin Wolftmp=/tmp/$$
29c75203c8SKevin Wolfstatus=1	# failure is the default!
30c75203c8SKevin Wolf
31c75203c8SKevin Wolf# get standard environment, filters and checks
32c75203c8SKevin Wolf. ./common.rc
33c75203c8SKevin Wolf. ./common.filter
34c75203c8SKevin Wolf
35c75203c8SKevin Wolf_supported_fmt qcow2
36c75203c8SKevin Wolf_supported_proto file
37c75203c8SKevin Wolf_supported_os Linux
38c75203c8SKevin Wolf
39c75203c8SKevin Wolffunction do_run_qemu()
40c75203c8SKevin Wolf{
41c75203c8SKevin Wolf    echo Testing: "$@"
42c75203c8SKevin Wolf    $QEMU -nographic -qmp stdio -serial none "$@"
43c75203c8SKevin Wolf    echo
44c75203c8SKevin Wolf}
45c75203c8SKevin Wolf
46c75203c8SKevin Wolffunction run_qemu()
47c75203c8SKevin Wolf{
48c75203c8SKevin Wolf    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
49c75203c8SKevin Wolf}
50c75203c8SKevin Wolf
51c75203c8SKevin Wolfsize=128M
52c75203c8SKevin Wolf
53c75203c8SKevin Wolf_make_test_img $size
54c75203c8SKevin Wolf
55c75203c8SKevin Wolfecho
56c75203c8SKevin Wolfecho === Missing ID ===
57c75203c8SKevin Wolfecho
58c75203c8SKevin Wolf
59c75203c8SKevin Wolfrun_qemu <<EOF
60c75203c8SKevin Wolf{ "execute": "qmp_capabilities" }
61c75203c8SKevin Wolf{ "execute": "blockdev-add",
62c75203c8SKevin Wolf  "arguments": {
63c75203c8SKevin Wolf      "options": {
64c75203c8SKevin Wolf        "driver": "$IMGFMT",
65c75203c8SKevin Wolf        "file": {
66c75203c8SKevin Wolf            "driver": "file",
67c75203c8SKevin Wolf            "filename": "$TEST_IMG"
68c75203c8SKevin Wolf        }
69c75203c8SKevin Wolf      }
70c75203c8SKevin Wolf    }
71c75203c8SKevin Wolf  }
72c75203c8SKevin Wolf{ "execute": "quit" }
73c75203c8SKevin WolfEOF
74c75203c8SKevin Wolf
75c75203c8SKevin Wolfecho
76c75203c8SKevin Wolfecho === aio=native without O_DIRECT ===
77c75203c8SKevin Wolfecho
78c75203c8SKevin Wolf
79c75203c8SKevin Wolfrun_qemu <<EOF
80c75203c8SKevin Wolf{ "execute": "qmp_capabilities" }
81c75203c8SKevin Wolf{ "execute": "blockdev-add",
82c75203c8SKevin Wolf  "arguments": {
83c75203c8SKevin Wolf      "options": {
84c75203c8SKevin Wolf        "driver": "$IMGFMT",
85c75203c8SKevin Wolf        "id": "disk",
86c75203c8SKevin Wolf        "aio": "native",
87c75203c8SKevin Wolf        "file": {
88c75203c8SKevin Wolf            "driver": "file",
89c75203c8SKevin Wolf            "filename": "$TEST_IMG"
90c75203c8SKevin Wolf        }
91c75203c8SKevin Wolf      }
92c75203c8SKevin Wolf    }
93c75203c8SKevin Wolf  }
94c75203c8SKevin Wolf{ "execute": "quit" }
95c75203c8SKevin WolfEOF
96c75203c8SKevin Wolf
97c75203c8SKevin Wolfecho
98c75203c8SKevin Wolfecho === Encrypted image ===
99c75203c8SKevin Wolfecho
100c75203c8SKevin Wolf
101c75203c8SKevin Wolf_make_test_img -o encryption=on $size
102*c3adb58fSMarkus Armbrusterrun_qemu -S <<EOF
103*c3adb58fSMarkus Armbruster{ "execute": "qmp_capabilities" }
104*c3adb58fSMarkus Armbruster{ "execute": "blockdev-add",
105*c3adb58fSMarkus Armbruster  "arguments": {
106*c3adb58fSMarkus Armbruster      "options": {
107*c3adb58fSMarkus Armbruster        "driver": "$IMGFMT",
108*c3adb58fSMarkus Armbruster        "id": "disk",
109*c3adb58fSMarkus Armbruster        "file": {
110*c3adb58fSMarkus Armbruster            "driver": "file",
111*c3adb58fSMarkus Armbruster            "filename": "$TEST_IMG"
112*c3adb58fSMarkus Armbruster        }
113*c3adb58fSMarkus Armbruster      }
114*c3adb58fSMarkus Armbruster    }
115*c3adb58fSMarkus Armbruster  }
116*c3adb58fSMarkus Armbruster{ "execute": "quit" }
117*c3adb58fSMarkus ArmbrusterEOF
118*c3adb58fSMarkus Armbruster
119c75203c8SKevin Wolfrun_qemu <<EOF
120c75203c8SKevin Wolf{ "execute": "qmp_capabilities" }
121c75203c8SKevin Wolf{ "execute": "blockdev-add",
122c75203c8SKevin Wolf  "arguments": {
123c75203c8SKevin Wolf      "options": {
124c75203c8SKevin Wolf        "driver": "$IMGFMT",
125c75203c8SKevin Wolf        "id": "disk",
126c75203c8SKevin Wolf        "file": {
127c75203c8SKevin Wolf            "driver": "file",
128c75203c8SKevin Wolf            "filename": "$TEST_IMG"
129c75203c8SKevin Wolf        }
130c75203c8SKevin Wolf      }
131c75203c8SKevin Wolf    }
132c75203c8SKevin Wolf  }
133c75203c8SKevin Wolf{ "execute": "quit" }
134c75203c8SKevin WolfEOF
135c75203c8SKevin Wolf
136c75203c8SKevin Wolf# success, all done
137c75203c8SKevin Wolfecho "*** done"
138c75203c8SKevin Wolfrm -f $seq.full
139c75203c8SKevin Wolfstatus=0
140