xref: /openbmc/qemu/tests/qemu-iotests/087 (revision d5b8336a6284fa4d75eaae3ac0bfb974cb7f5f4a)
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 Wolfstatus=1	# failure is the default!
29c75203c8SKevin Wolf
30c75203c8SKevin Wolf# get standard environment, filters and checks
31c75203c8SKevin Wolf. ./common.rc
32c75203c8SKevin Wolf. ./common.filter
33c75203c8SKevin Wolf
34c75203c8SKevin Wolf_supported_fmt qcow2
35c75203c8SKevin Wolf_supported_proto file
36c75203c8SKevin Wolf_supported_os Linux
37c75203c8SKevin Wolf
38c75203c8SKevin Wolffunction do_run_qemu()
39c75203c8SKevin Wolf{
40c75203c8SKevin Wolf    echo Testing: "$@"
41c75203c8SKevin Wolf    $QEMU -nographic -qmp stdio -serial none "$@"
42c75203c8SKevin Wolf    echo
43c75203c8SKevin Wolf}
44c75203c8SKevin Wolf
45c75203c8SKevin Wolffunction run_qemu()
46c75203c8SKevin Wolf{
47e6ff69bfSDaniel P. Berrange    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
48e6ff69bfSDaniel P. Berrange                          | _filter_qemu | _filter_imgfmt \
494dd7b8d3SMax Reitz                          | sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
50c75203c8SKevin Wolf}
51c75203c8SKevin Wolf
52c75203c8SKevin Wolfsize=128M
53c75203c8SKevin Wolf
54c75203c8SKevin Wolf_make_test_img $size
55c75203c8SKevin Wolf
56c75203c8SKevin Wolfecho
57be4b67bcSMax Reitzecho === Missing ID and node-name ===
58c75203c8SKevin Wolfecho
59c75203c8SKevin Wolf
60c75203c8SKevin Wolfrun_qemu <<EOF
61c75203c8SKevin Wolf{ "execute": "qmp_capabilities" }
62c75203c8SKevin Wolf{ "execute": "blockdev-add",
63c75203c8SKevin Wolf  "arguments": {
64c75203c8SKevin Wolf      "driver": "$IMGFMT",
65c75203c8SKevin Wolf      "file": {
66c75203c8SKevin Wolf          "driver": "file",
67c75203c8SKevin Wolf          "filename": "$TEST_IMG"
68c75203c8SKevin Wolf      }
69c75203c8SKevin Wolf    }
70c75203c8SKevin Wolf  }
71c75203c8SKevin Wolf{ "execute": "quit" }
72c75203c8SKevin WolfEOF
73c75203c8SKevin Wolf
74c75203c8SKevin Wolfecho
75f2d953ecSKevin Wolfecho === Duplicate ID ===
76f2d953ecSKevin Wolfecho
77f2d953ecSKevin Wolf
785feb08edSKevin Wolfrun_qemu -drive driver=$IMGFMT,id=disk,node-name=test-node,file="$TEST_IMG" <<EOF
79f2d953ecSKevin Wolf{ "execute": "qmp_capabilities" }
80f2d953ecSKevin Wolf{ "execute": "blockdev-add",
81f2d953ecSKevin Wolf  "arguments": {
82f2d953ecSKevin Wolf      "driver": "$IMGFMT",
8390d9d301SKevin Wolf      "node-name": "disk",
8490d9d301SKevin Wolf      "file": {
85*d5b8336aSFam Zheng          "driver": "null-co"
8690d9d301SKevin Wolf      }
8790d9d301SKevin Wolf    }
8890d9d301SKevin Wolf  }
8990d9d301SKevin Wolf{ "execute": "blockdev-add",
9090d9d301SKevin Wolf  "arguments": {
9190d9d301SKevin Wolf      "driver": "$IMGFMT",
9290d9d301SKevin Wolf      "node-name": "test-node",
9390d9d301SKevin Wolf      "file": {
94*d5b8336aSFam Zheng          "driver": "null-co"
9590d9d301SKevin Wolf      }
9690d9d301SKevin Wolf    }
9790d9d301SKevin Wolf  }
98f2d953ecSKevin Wolf{ "execute": "quit" }
99f2d953ecSKevin WolfEOF
100f2d953ecSKevin Wolf
101f2d953ecSKevin Wolfecho
102c75203c8SKevin Wolfecho === aio=native without O_DIRECT ===
103c75203c8SKevin Wolfecho
104c75203c8SKevin Wolf
105c75203c8SKevin Wolfrun_qemu <<EOF
106c75203c8SKevin Wolf{ "execute": "qmp_capabilities" }
107c75203c8SKevin Wolf{ "execute": "blockdev-add",
108c75203c8SKevin Wolf  "arguments": {
109c75203c8SKevin Wolf      "driver": "$IMGFMT",
1105feb08edSKevin Wolf      "node-name": "disk",
111c75203c8SKevin Wolf      "file": {
112c75203c8SKevin Wolf          "driver": "file",
1130a4279d9SKevin Wolf          "filename": "$TEST_IMG",
1140a4279d9SKevin Wolf          "aio": "native"
115c75203c8SKevin Wolf      }
116c75203c8SKevin Wolf    }
117c75203c8SKevin Wolf  }
118c75203c8SKevin Wolf{ "execute": "quit" }
119c75203c8SKevin WolfEOF
120c75203c8SKevin Wolf
121c75203c8SKevin Wolfecho
122c75203c8SKevin Wolfecho === Encrypted image ===
123c75203c8SKevin Wolfecho
124c75203c8SKevin Wolf
125c75203c8SKevin Wolf_make_test_img -o encryption=on $size
126c3adb58fSMarkus Armbrusterrun_qemu -S <<EOF
127c3adb58fSMarkus Armbruster{ "execute": "qmp_capabilities" }
128c3adb58fSMarkus Armbruster{ "execute": "blockdev-add",
129c3adb58fSMarkus Armbruster  "arguments": {
130c3adb58fSMarkus Armbruster      "driver": "$IMGFMT",
1315feb08edSKevin Wolf      "node-name": "disk",
132c3adb58fSMarkus Armbruster      "file": {
133c3adb58fSMarkus Armbruster          "driver": "file",
134c3adb58fSMarkus Armbruster          "filename": "$TEST_IMG"
135c3adb58fSMarkus Armbruster      }
136c3adb58fSMarkus Armbruster    }
137c3adb58fSMarkus Armbruster  }
138c3adb58fSMarkus Armbruster{ "execute": "quit" }
139c3adb58fSMarkus ArmbrusterEOF
140c3adb58fSMarkus Armbruster
141c75203c8SKevin Wolfrun_qemu <<EOF
142c75203c8SKevin Wolf{ "execute": "qmp_capabilities" }
143c75203c8SKevin Wolf{ "execute": "blockdev-add",
144c75203c8SKevin Wolf  "arguments": {
145c75203c8SKevin Wolf      "driver": "$IMGFMT",
1465feb08edSKevin Wolf      "node-name": "disk",
147c75203c8SKevin Wolf      "file": {
148c75203c8SKevin Wolf          "driver": "file",
149c75203c8SKevin Wolf          "filename": "$TEST_IMG"
150c75203c8SKevin Wolf      }
151c75203c8SKevin Wolf    }
152c75203c8SKevin Wolf  }
153c75203c8SKevin Wolf{ "execute": "quit" }
154c75203c8SKevin WolfEOF
155c75203c8SKevin Wolf
156fe509ee2SFam Zhengecho
157fe509ee2SFam Zhengecho === Missing driver ===
158fe509ee2SFam Zhengecho
159fe509ee2SFam Zheng
160fe509ee2SFam Zheng_make_test_img -o encryption=on $size
161fe509ee2SFam Zhengrun_qemu -S <<EOF
162fe509ee2SFam Zheng{ "execute": "qmp_capabilities" }
163fe509ee2SFam Zheng{ "execute": "blockdev-add",
164fe509ee2SFam Zheng  "arguments": {
1655feb08edSKevin Wolf      "node-name": "disk"
166fe509ee2SFam Zheng    }
167fe509ee2SFam Zheng  }
168fe509ee2SFam Zheng{ "execute": "quit" }
169fe509ee2SFam ZhengEOF
170fe509ee2SFam Zheng
171c75203c8SKevin Wolf# success, all done
172c75203c8SKevin Wolfecho "*** done"
173c75203c8SKevin Wolfrm -f $seq.full
174c75203c8SKevin Wolfstatus=0
175