xref: /openbmc/qemu/tests/qemu-iotests/186 (revision 627f607e3dddb23cef69374c8bfb09a33d19926a)
1e1824e58SKevin Wolf#!/bin/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 Wolfhere=`pwd`
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
41e1824e58SKevin Wolf_supported_proto file
42e1824e58SKevin Wolf_supported_os Linux
43e1824e58SKevin Wolf
44e1824e58SKevin Wolfif [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
45e1824e58SKevin Wolf    _notrun "Requires a PC machine"
46e1824e58SKevin Wolffi
47e1824e58SKevin Wolf
48e1824e58SKevin Wolffunction do_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
63e1824e58SKevin Wolffunction check_info_block()
64e1824e58SKevin Wolf{
65e1824e58SKevin Wolf    echo "info block" |
6605b4cd5dSKevin Wolf    do_run_qemu "$@" | _filter_win32 | _filter_hmp | _filter_qemu |
67*627f607eSAlberto 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
91e1824e58SKevin Wolf    check_info_block -blockdev driver=null-co,node-name=null -device $dev,drive=null
92e1824e58SKevin Wolf    check_info_block -blockdev driver=null-co,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
102e1824e58SKevin Wolf    check_info_block -drive if=none,driver=null-co,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
110e1824e58SKevin Wolf    check_info_block -drive if=none,driver=null-co,node-name=null -device $dev,drive=none0
111e1824e58SKevin Wolf    check_info_block -drive if=none,driver=null-co,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
130e1824e58SKevin Wolfcheck_info_block -drive if=floppy,driver=null-co
131e1824e58SKevin Wolf
132e1824e58SKevin Wolfcheck_info_block -drive if=ide,driver=null-co
133e1824e58SKevin Wolfcheck_info_block -drive if=ide,media=cdrom
134e1824e58SKevin Wolfcheck_info_block -drive if=ide,driver=null-co,media=cdrom
135e1824e58SKevin Wolf
136e1824e58SKevin Wolfcheck_info_block -drive if=virtio,driver=null-co
137e1824e58SKevin Wolf
138e1824e58SKevin Wolfcheck_info_block -drive if=pflash,driver=null-co,size=1M
139e1824e58SKevin Wolf
140e1824e58SKevin Wolf# success, all done
141e1824e58SKevin Wolfecho "*** done"
142e1824e58SKevin Wolfrm -f $seq.full
143e1824e58SKevin Wolfstatus=0
144