xref: /openbmc/qemu/tests/qemu-iotests/186 (revision 7f709ce7)
1#!/bin/bash
2#
3# Test 'info block' with all kinds of configurations
4#
5# Copyright (C) 2017 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`
28status=1	# failure is the default!
29
30_cleanup()
31{
32	_cleanup_test_img
33}
34trap "_cleanup; exit \$status" 0 1 2 3 15
35
36# get standard environment, filters and checks
37. ./common.rc
38. ./common.filter
39
40_supported_fmt qcow2
41_supported_proto file
42_supported_os Linux
43
44if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
45    _notrun "Requires a PC machine"
46fi
47
48function do_run_qemu()
49{
50    echo Testing: "$@"
51
52    (
53        if ! test -t 0; then
54            while read cmd; do
55                echo $cmd
56            done
57        fi
58        echo quit
59    ) | $QEMU -S -display none -device virtio-scsi-pci -monitor stdio "$@" 2>&1
60    echo
61}
62
63function check_info_block()
64{
65    echo "info block" |
66    do_run_qemu "$@" | _filter_win32 | _filter_hmp | _filter_qemu |
67        _filter_generated_node_ids
68}
69
70
71size=64M
72_make_test_img $size
73
74removable="floppy ide-cd scsi-cd"
75fixed="ide-hd scsi-hd virtio-blk-pci"
76
77echo
78echo "=== Empty drives ==="
79echo
80
81for dev in $removable; do
82    check_info_block -device $dev
83    check_info_block -device $dev,id=qdev_id
84done
85
86echo
87echo "=== -blockdev/-device=<node-name> ==="
88echo
89
90for dev in $fixed $removable; do
91    check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null
92    check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id
93done
94
95echo
96echo "=== -drive if=none/-device=<node-name> ==="
97echo
98
99# This creates two BlockBackends that will show up in 'info block'!
100# A monitor-owned one from -drive, and anonymous one from -device
101for dev in $fixed $removable; do
102    check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=null,id=qdev_id
103done
104
105echo
106echo "=== -drive if=none/-device=<bb-name> (with medium) ==="
107echo
108
109for dev in $fixed $removable; do
110    check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0
111    check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0,id=qdev_id
112done
113
114echo
115echo "=== -drive if=none/-device=<bb-name> (without medium) ==="
116echo
117
118check_info_block -drive if=none
119
120for dev in $removable; do
121    check_info_block -drive if=none -device $dev,drive=none0
122    check_info_block -drive if=none -device $dev,drive=none0,id=qdev_id
123done
124
125echo
126echo "=== -drive if=... ==="
127echo
128
129check_info_block -drive if=floppy
130check_info_block -drive if=floppy,driver=null-co
131
132check_info_block -drive if=ide,driver=null-co
133check_info_block -drive if=ide,media=cdrom
134check_info_block -drive if=ide,driver=null-co,media=cdrom
135
136check_info_block -drive if=scsi,driver=null-co
137check_info_block -drive if=scsi,media=cdrom
138check_info_block -drive if=scsi,driver=null-co,media=cdrom
139
140check_info_block -drive if=virtio,driver=null-co
141
142check_info_block -drive if=pflash,driver=null-co,size=1M
143
144# success, all done
145echo "*** done"
146rm -f $seq.full
147status=0
148