xref: /openbmc/qemu/tests/qemu-iotests/051 (revision 47e5df2146e8b6cd1c093720461928e66f824222)
1*47e5df21SKevin Wolf#!/bin/bash
2*47e5df21SKevin Wolf#
3*47e5df21SKevin Wolf# Test command line configuration of block devices and driver-specific options
4*47e5df21SKevin Wolf#
5*47e5df21SKevin Wolf# Copyright (C) 2013 Red Hat, Inc.
6*47e5df21SKevin Wolf#
7*47e5df21SKevin Wolf# This program is free software; you can redistribute it and/or modify
8*47e5df21SKevin Wolf# it under the terms of the GNU General Public License as published by
9*47e5df21SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10*47e5df21SKevin Wolf# (at your option) any later version.
11*47e5df21SKevin Wolf#
12*47e5df21SKevin Wolf# This program is distributed in the hope that it will be useful,
13*47e5df21SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*47e5df21SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*47e5df21SKevin Wolf# GNU General Public License for more details.
16*47e5df21SKevin Wolf#
17*47e5df21SKevin Wolf# You should have received a copy of the GNU General Public License
18*47e5df21SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*47e5df21SKevin Wolf#
20*47e5df21SKevin Wolf
21*47e5df21SKevin Wolf# creator
22*47e5df21SKevin Wolfowner=kwolf@redhat.com
23*47e5df21SKevin Wolf
24*47e5df21SKevin Wolfseq=`basename $0`
25*47e5df21SKevin Wolfecho "QA output created by $seq"
26*47e5df21SKevin Wolf
27*47e5df21SKevin Wolfhere=`pwd`
28*47e5df21SKevin Wolftmp=/tmp/$$
29*47e5df21SKevin Wolfstatus=1	# failure is the default!
30*47e5df21SKevin Wolf
31*47e5df21SKevin Wolf_cleanup()
32*47e5df21SKevin Wolf{
33*47e5df21SKevin Wolf	_cleanup_test_img
34*47e5df21SKevin Wolf}
35*47e5df21SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
36*47e5df21SKevin Wolf
37*47e5df21SKevin Wolf# get standard environment, filters and checks
38*47e5df21SKevin Wolf. ./common.rc
39*47e5df21SKevin Wolf. ./common.filter
40*47e5df21SKevin Wolf
41*47e5df21SKevin Wolf_supported_fmt qcow2
42*47e5df21SKevin Wolf_supported_proto file
43*47e5df21SKevin Wolf_supported_os Linux
44*47e5df21SKevin Wolf
45*47e5df21SKevin Wolffunction do_run_qemu()
46*47e5df21SKevin Wolf{
47*47e5df21SKevin Wolf    echo Testing: "$@"
48*47e5df21SKevin Wolf    echo quit | $QEMU -nographic -monitor stdio -serial none "$@"
49*47e5df21SKevin Wolf    echo
50*47e5df21SKevin Wolf}
51*47e5df21SKevin Wolf
52*47e5df21SKevin Wolffunction run_qemu()
53*47e5df21SKevin Wolf{
54*47e5df21SKevin Wolf    do_run_qemu "$@" 2>&1 | _filter_testdir
55*47e5df21SKevin Wolf}
56*47e5df21SKevin Wolf
57*47e5df21SKevin Wolfsize=128M
58*47e5df21SKevin Wolf
59*47e5df21SKevin Wolf_make_test_img $size
60*47e5df21SKevin Wolf
61*47e5df21SKevin Wolfecho
62*47e5df21SKevin Wolfecho === Unknown option ===
63*47e5df21SKevin Wolfecho
64*47e5df21SKevin Wolf
65*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=
66*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=on
67*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=1234
68*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,unknown_opt=foo
69*47e5df21SKevin Wolf
70*47e5df21SKevin Wolf
71*47e5df21SKevin Wolfecho
72*47e5df21SKevin Wolfecho === Enable and disable lazy refcounting on the command line, plus some invalid values ===
73*47e5df21SKevin Wolfecho
74*47e5df21SKevin Wolf
75*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=on
76*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=off
77*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=
78*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=42
79*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=foo
80*47e5df21SKevin Wolf
81*47e5df21SKevin Wolf
82*47e5df21SKevin Wolfecho
83*47e5df21SKevin Wolfecho === With version 2 images enabling lazy refcounts must fail ===
84*47e5df21SKevin Wolfecho
85*47e5df21SKevin Wolf
86*47e5df21SKevin Wolf_make_test_img -ocompat=0.10 $size
87*47e5df21SKevin Wolf
88*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=on
89*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,format=qcow2,lazy_refcounts=off
90*47e5df21SKevin Wolf
91*47e5df21SKevin Wolfecho
92*47e5df21SKevin Wolfecho === No medium ===
93*47e5df21SKevin Wolfecho
94*47e5df21SKevin Wolf
95*47e5df21SKevin Wolfrun_qemu -drive if=floppy
96*47e5df21SKevin Wolfrun_qemu -drive if=ide,media=cdrom
97*47e5df21SKevin Wolfrun_qemu -drive if=scsi,media=cdrom
98*47e5df21SKevin Wolf
99*47e5df21SKevin Wolfrun_qemu -drive if=ide
100*47e5df21SKevin Wolfrun_qemu -drive if=virtio
101*47e5df21SKevin Wolfrun_qemu -drive if=scsi
102*47e5df21SKevin Wolf
103*47e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device ide-cd,drive=disk
104*47e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-cd,drive=disk
105*47e5df21SKevin Wolf
106*47e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device ide-drive,drive=disk
107*47e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device ide-hd,drive=disk
108*47e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-disk,drive=disk
109*47e5df21SKevin Wolfrun_qemu -drive if=none,id=disk -device lsi53c895a -device scsi-hd,drive=disk
110*47e5df21SKevin Wolf
111*47e5df21SKevin Wolfecho
112*47e5df21SKevin Wolfecho === Read-only ===
113*47e5df21SKevin Wolfecho
114*47e5df21SKevin Wolf
115*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=floppy,readonly=on
116*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=ide,media=cdrom,readonly=on
117*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=scsi,media=cdrom,readonly=on
118*47e5df21SKevin Wolf
119*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=ide,readonly=on
120*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=virtio,readonly=on
121*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=scsi,readonly=on
122*47e5df21SKevin Wolf
123*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device ide-cd,drive=disk
124*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-cd,drive=disk
125*47e5df21SKevin Wolf
126*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device ide-drive,drive=disk
127*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device ide-hd,drive=disk
128*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-disk,drive=disk
129*47e5df21SKevin Wolfrun_qemu -drive file=$TEST_IMG,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-hd,drive=disk
130*47e5df21SKevin Wolf
131*47e5df21SKevin Wolfecho
132*47e5df21SKevin Wolfecho === Cache modes ===
133*47e5df21SKevin Wolfecho
134*47e5df21SKevin Wolf
135*47e5df21SKevin Wolf# Cannot use the test image because cache=none might not work on the host FS
136*47e5df21SKevin Wolf# Use cdrom so that we won't get errors about missing media
137*47e5df21SKevin Wolf
138*47e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=none
139*47e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=directsync
140*47e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=writeback
141*47e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=writethrough
142*47e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=unsafe
143*47e5df21SKevin Wolfrun_qemu -drive media=cdrom,cache=invalid_value
144*47e5df21SKevin Wolf
145*47e5df21SKevin Wolf# success, all done
146*47e5df21SKevin Wolfecho "*** done"
147*47e5df21SKevin Wolfrm -f $seq.full
148*47e5df21SKevin Wolfstatus=0
149