xref: /openbmc/qemu/tests/qemu-iotests/186 (revision 13b5ae94)
1#!/usr/bin/env bash
2# group: rw auto
3#
4# Test 'info block' with all kinds of configurations
5#
6# Copyright (C) 2017 Red Hat, Inc.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20#
21
22# creator
23owner=kwolf@redhat.com
24
25seq=`basename $0`
26echo "QA output created by $seq"
27
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 fuse
42_require_drivers null-co
43_require_devices virtio-scsi-pci
44
45if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
46    _notrun "Requires a PC machine"
47fi
48
49do_run_qemu()
50{
51    echo Testing: "$@"
52
53    (
54        if ! test -t 0; then
55            while read cmd; do
56                echo $cmd
57            done
58        fi
59        echo quit
60    ) | $QEMU -S -display none -device virtio-scsi-pci -monitor stdio "$@" 2>&1
61    echo
62}
63
64check_info_block()
65{
66    echo "info block" |
67    do_run_qemu "$@" | _filter_win32 | _filter_hmp | _filter_qemu |
68        _filter_generated_node_ids | _filter_qom_path
69}
70
71
72size=64M
73_make_test_img $size
74
75removable="floppy ide-cd scsi-cd"
76fixed="ide-hd scsi-hd virtio-blk-pci"
77
78echo
79echo "=== Empty drives ==="
80echo
81
82for dev in $removable; do
83    check_info_block -device $dev
84    check_info_block -device $dev,id=qdev_id
85done
86
87echo
88echo "=== -blockdev/-device=<node-name> ==="
89echo
90
91for dev in $fixed $removable; do
92    check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null
93    check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
94done
95
96echo
97echo "=== -drive if=none/-device=<node-name> ==="
98echo
99
100# This creates two BlockBackends that will show up in 'info block'!
101# A monitor-owned one from -drive, and anonymous one from -device
102for dev in $fixed $removable; do
103    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
104done
105
106echo
107echo "=== -drive if=none/-device=<bb-name> (with medium) ==="
108echo
109
110for dev in $fixed $removable; do
111    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0
112    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0,id=qdev_id
113done
114
115echo
116echo "=== -drive if=none/-device=<bb-name> (without medium) ==="
117echo
118
119check_info_block -drive if=none
120
121for dev in $removable; do
122    check_info_block -drive if=none -device $dev,drive=none0
123    check_info_block -drive if=none -device $dev,drive=none0,id=qdev_id
124done
125
126echo
127echo "=== -drive if=... ==="
128echo
129
130check_info_block -drive if=floppy
131check_info_block -drive if=floppy,driver=null-co,read-zeroes=on
132
133check_info_block -drive if=ide,driver=null-co,read-zeroes=on
134check_info_block -drive if=ide,media=cdrom
135check_info_block -drive if=ide,driver=null-co,read-zeroes=on,media=cdrom
136
137check_info_block -drive if=virtio,driver=null-co,read-zeroes=on
138
139check_info_block -drive if=pflash,driver=null-co,read-zeroes=on,size=1M
140
141# success, all done
142echo "*** done"
143rm -f $seq.full
144status=0
145