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