xref: /qemu/tests/qemu-iotests/157 (revision 62ed9fa991488b5ed6b8a2cbcb64182d7a5378f5)
1*62ed9fa9SKevin Wolf#!/bin/bash
2*62ed9fa9SKevin Wolf#
3*62ed9fa9SKevin Wolf# Test command line configuration of block devices with qdev
4*62ed9fa9SKevin Wolf#
5*62ed9fa9SKevin Wolf# Copyright (C) 2016 Red Hat, Inc.
6*62ed9fa9SKevin Wolf#
7*62ed9fa9SKevin Wolf# This program is free software; you can redistribute it and/or modify
8*62ed9fa9SKevin Wolf# it under the terms of the GNU General Public License as published by
9*62ed9fa9SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10*62ed9fa9SKevin Wolf# (at your option) any later version.
11*62ed9fa9SKevin Wolf#
12*62ed9fa9SKevin Wolf# This program is distributed in the hope that it will be useful,
13*62ed9fa9SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*62ed9fa9SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*62ed9fa9SKevin Wolf# GNU General Public License for more details.
16*62ed9fa9SKevin Wolf#
17*62ed9fa9SKevin Wolf# You should have received a copy of the GNU General Public License
18*62ed9fa9SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*62ed9fa9SKevin Wolf#
20*62ed9fa9SKevin Wolf
21*62ed9fa9SKevin Wolf# creator
22*62ed9fa9SKevin Wolfowner=kwolf@redhat.com
23*62ed9fa9SKevin Wolf
24*62ed9fa9SKevin Wolfseq="$(basename $0)"
25*62ed9fa9SKevin Wolfecho "QA output created by $seq"
26*62ed9fa9SKevin Wolf
27*62ed9fa9SKevin Wolfhere="$PWD"
28*62ed9fa9SKevin Wolfstatus=1	# failure is the default!
29*62ed9fa9SKevin Wolf
30*62ed9fa9SKevin Wolf_cleanup()
31*62ed9fa9SKevin Wolf{
32*62ed9fa9SKevin Wolf	_cleanup_test_img
33*62ed9fa9SKevin Wolf}
34*62ed9fa9SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
35*62ed9fa9SKevin Wolf
36*62ed9fa9SKevin Wolf# get standard environment, filters and checks
37*62ed9fa9SKevin Wolf. ./common.rc
38*62ed9fa9SKevin Wolf. ./common.filter
39*62ed9fa9SKevin Wolf
40*62ed9fa9SKevin Wolf_supported_fmt generic
41*62ed9fa9SKevin Wolf_supported_proto file
42*62ed9fa9SKevin Wolf_supported_os Linux
43*62ed9fa9SKevin Wolf
44*62ed9fa9SKevin Wolffunction do_run_qemu()
45*62ed9fa9SKevin Wolf{
46*62ed9fa9SKevin Wolf    echo Testing: "$@"
47*62ed9fa9SKevin Wolf    (
48*62ed9fa9SKevin Wolf        if ! test -t 0; then
49*62ed9fa9SKevin Wolf            while read cmd; do
50*62ed9fa9SKevin Wolf                echo $cmd
51*62ed9fa9SKevin Wolf            done
52*62ed9fa9SKevin Wolf        fi
53*62ed9fa9SKevin Wolf        echo quit
54*62ed9fa9SKevin Wolf    ) | $QEMU -nodefaults -nographic -monitor stdio -serial none "$@"
55*62ed9fa9SKevin Wolf    echo
56*62ed9fa9SKevin Wolf}
57*62ed9fa9SKevin Wolf
58*62ed9fa9SKevin Wolffunction run_qemu()
59*62ed9fa9SKevin Wolf{
60*62ed9fa9SKevin Wolf    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_generated_node_ids
61*62ed9fa9SKevin Wolf}
62*62ed9fa9SKevin Wolf
63*62ed9fa9SKevin Wolf
64*62ed9fa9SKevin Wolfsize=128M
65*62ed9fa9SKevin Wolfdrive="if=none,file=$TEST_IMG,driver=$IMGFMT"
66*62ed9fa9SKevin Wolf
67*62ed9fa9SKevin Wolf_make_test_img $size
68*62ed9fa9SKevin Wolf
69*62ed9fa9SKevin Wolfecho
70*62ed9fa9SKevin Wolfecho "=== Setting WCE with qdev and with manually created BB ==="
71*62ed9fa9SKevin Wolfecho
72*62ed9fa9SKevin Wolf
73*62ed9fa9SKevin Wolf# The qdev option takes precedence, but if it isn't given or 'auto', the BB
74*62ed9fa9SKevin Wolf# option is used instead.
75*62ed9fa9SKevin Wolf
76*62ed9fa9SKevin Wolffor cache in "writeback" "writethrough"; do
77*62ed9fa9SKevin Wolf    for wce in "" ",write-cache=auto" ",write-cache=on" ",write-cache=off"; do
78*62ed9fa9SKevin Wolf        echo "info block" \
79*62ed9fa9SKevin Wolf            | run_qemu -drive "$drive,cache=$cache" \
80*62ed9fa9SKevin Wolf                       -device "virtio-blk,drive=none0$wce" \
81*62ed9fa9SKevin Wolf            | grep -e "Testing" -e "Cache mode"
82*62ed9fa9SKevin Wolf    done
83*62ed9fa9SKevin Wolfdone
84*62ed9fa9SKevin Wolf
85*62ed9fa9SKevin Wolf# success, all done
86*62ed9fa9SKevin Wolfecho "*** done"
87*62ed9fa9SKevin Wolfrm -f $seq.full
88*62ed9fa9SKevin Wolfstatus=0
89