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