xref: /qemu/tests/qemu-iotests/186 (revision a6862418fec40727b392c86dc13d9ec980efcb15)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2e1824e58SKevin Wolf#
3e1824e58SKevin Wolf# Test 'info block' with all kinds of configurations
4e1824e58SKevin Wolf#
5e1824e58SKevin Wolf# Copyright (C) 2017 Red Hat, Inc.
6e1824e58SKevin Wolf#
7e1824e58SKevin Wolf# This program is free software; you can redistribute it and/or modify
8e1824e58SKevin Wolf# it under the terms of the GNU General Public License as published by
9e1824e58SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
10e1824e58SKevin Wolf# (at your option) any later version.
11e1824e58SKevin Wolf#
12e1824e58SKevin Wolf# This program is distributed in the hope that it will be useful,
13e1824e58SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
14e1824e58SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15e1824e58SKevin Wolf# GNU General Public License for more details.
16e1824e58SKevin Wolf#
17e1824e58SKevin Wolf# You should have received a copy of the GNU General Public License
18e1824e58SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19e1824e58SKevin Wolf#
20e1824e58SKevin Wolf
21e1824e58SKevin Wolf# creator
22e1824e58SKevin Wolfowner=kwolf@redhat.com
23e1824e58SKevin Wolf
24e1824e58SKevin Wolfseq=`basename $0`
25e1824e58SKevin Wolfecho "QA output created by $seq"
26e1824e58SKevin Wolf
27e1824e58SKevin Wolfstatus=1	# failure is the default!
28e1824e58SKevin Wolf
29e1824e58SKevin Wolf_cleanup()
30e1824e58SKevin Wolf{
31e1824e58SKevin Wolf	_cleanup_test_img
32e1824e58SKevin Wolf}
33e1824e58SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
34e1824e58SKevin Wolf
35e1824e58SKevin Wolf# get standard environment, filters and checks
36e1824e58SKevin Wolf. ./common.rc
37e1824e58SKevin Wolf. ./common.filter
38e1824e58SKevin Wolf
39e1824e58SKevin Wolf_supported_fmt qcow2
40e1824e58SKevin Wolf_supported_proto file
41e1824e58SKevin Wolf
42e1824e58SKevin Wolfif [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
43e1824e58SKevin Wolf    _notrun "Requires a PC machine"
44e1824e58SKevin Wolffi
45e1824e58SKevin Wolf
468cedcffdSEric Blakedo_run_qemu()
47e1824e58SKevin Wolf{
48e1824e58SKevin Wolf    echo Testing: "$@"
49e1824e58SKevin Wolf
50e1824e58SKevin Wolf    (
51e1824e58SKevin Wolf        if ! test -t 0; then
52e1824e58SKevin Wolf            while read cmd; do
53e1824e58SKevin Wolf                echo $cmd
54e1824e58SKevin Wolf            done
55e1824e58SKevin Wolf        fi
56e1824e58SKevin Wolf        echo quit
5705b4cd5dSKevin Wolf    ) | $QEMU -S -display none -device virtio-scsi-pci -monitor stdio "$@" 2>&1
58e1824e58SKevin Wolf    echo
59e1824e58SKevin Wolf}
60e1824e58SKevin Wolf
618cedcffdSEric Blakecheck_info_block()
62e1824e58SKevin Wolf{
63e1824e58SKevin Wolf    echo "info block" |
6405b4cd5dSKevin Wolf    do_run_qemu "$@" | _filter_win32 | _filter_hmp | _filter_qemu |
65627f607eSAlberto Garcia        _filter_generated_node_ids | _filter_qom_path
66e1824e58SKevin Wolf}
67e1824e58SKevin Wolf
68e1824e58SKevin Wolf
69e1824e58SKevin Wolfsize=64M
70e1824e58SKevin Wolf_make_test_img $size
71e1824e58SKevin Wolf
72e1824e58SKevin Wolfremovable="floppy ide-cd scsi-cd"
73e1824e58SKevin Wolffixed="ide-hd scsi-hd virtio-blk-pci"
74e1824e58SKevin Wolf
75e1824e58SKevin Wolfecho
76e1824e58SKevin Wolfecho "=== Empty drives ==="
77e1824e58SKevin Wolfecho
78e1824e58SKevin Wolf
79e1824e58SKevin Wolffor dev in $removable; do
80e1824e58SKevin Wolf    check_info_block -device $dev
81e1824e58SKevin Wolf    check_info_block -device $dev,id=qdev_id
82e1824e58SKevin Wolfdone
83e1824e58SKevin Wolf
84e1824e58SKevin Wolfecho
85e1824e58SKevin Wolfecho "=== -blockdev/-device=<node-name> ==="
86e1824e58SKevin Wolfecho
87e1824e58SKevin Wolf
88e1824e58SKevin Wolffor dev in $fixed $removable; do
89*a6862418SAndrey Shinkevich    check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null
90*a6862418SAndrey Shinkevich    check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
91e1824e58SKevin Wolfdone
92e1824e58SKevin Wolf
93e1824e58SKevin Wolfecho
94e1824e58SKevin Wolfecho "=== -drive if=none/-device=<node-name> ==="
95e1824e58SKevin Wolfecho
96e1824e58SKevin Wolf
97e1824e58SKevin Wolf# This creates two BlockBackends that will show up in 'info block'!
98e1824e58SKevin Wolf# A monitor-owned one from -drive, and anonymous one from -device
99e1824e58SKevin Wolffor dev in $fixed $removable; do
100*a6862418SAndrey Shinkevich    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
101e1824e58SKevin Wolfdone
102e1824e58SKevin Wolf
103e1824e58SKevin Wolfecho
104e1824e58SKevin Wolfecho "=== -drive if=none/-device=<bb-name> (with medium) ==="
105e1824e58SKevin Wolfecho
106e1824e58SKevin Wolf
107e1824e58SKevin Wolffor dev in $fixed $removable; do
108*a6862418SAndrey Shinkevich    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0
109*a6862418SAndrey Shinkevich    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0,id=qdev_id
110e1824e58SKevin Wolfdone
111e1824e58SKevin Wolf
112e1824e58SKevin Wolfecho
113e1824e58SKevin Wolfecho "=== -drive if=none/-device=<bb-name> (without medium) ==="
114e1824e58SKevin Wolfecho
115e1824e58SKevin Wolf
116e1824e58SKevin Wolfcheck_info_block -drive if=none
117e1824e58SKevin Wolf
118e1824e58SKevin Wolffor dev in $removable; do
119e1824e58SKevin Wolf    check_info_block -drive if=none -device $dev,drive=none0
120e1824e58SKevin Wolf    check_info_block -drive if=none -device $dev,drive=none0,id=qdev_id
121e1824e58SKevin Wolfdone
122e1824e58SKevin Wolf
123e1824e58SKevin Wolfecho
124e1824e58SKevin Wolfecho "=== -drive if=... ==="
125e1824e58SKevin Wolfecho
126e1824e58SKevin Wolf
127e1824e58SKevin Wolfcheck_info_block -drive if=floppy
128*a6862418SAndrey Shinkevichcheck_info_block -drive if=floppy,driver=null-co,read-zeroes=on
129e1824e58SKevin Wolf
130*a6862418SAndrey Shinkevichcheck_info_block -drive if=ide,driver=null-co,read-zeroes=on
131e1824e58SKevin Wolfcheck_info_block -drive if=ide,media=cdrom
132*a6862418SAndrey Shinkevichcheck_info_block -drive if=ide,driver=null-co,read-zeroes=on,media=cdrom
133e1824e58SKevin Wolf
134*a6862418SAndrey Shinkevichcheck_info_block -drive if=virtio,driver=null-co,read-zeroes=on
135e1824e58SKevin Wolf
136*a6862418SAndrey Shinkevichcheck_info_block -drive if=pflash,driver=null-co,read-zeroes=on,size=1M
137e1824e58SKevin Wolf
138e1824e58SKevin Wolf# success, all done
139e1824e58SKevin Wolfecho "*** done"
140e1824e58SKevin Wolfrm -f $seq.full
141e1824e58SKevin Wolfstatus=0
142