xref: /openbmc/qemu/tests/qemu-iotests/186 (revision 6a50f64ca01d0a7b97f14f069762bfd88160f31e)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir 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
43*d043f461SFabiano Rosas_require_devices virtio-scsi-pci
44e1824e58SKevin Wolf
45e1824e58SKevin Wolfif [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then
46e1824e58SKevin Wolf    _notrun "Requires a PC machine"
47e1824e58SKevin Wolffi
48e1824e58SKevin Wolf
498cedcffdSEric Blakedo_run_qemu()
50e1824e58SKevin Wolf{
51e1824e58SKevin Wolf    echo Testing: "$@"
52e1824e58SKevin Wolf
53e1824e58SKevin Wolf    (
54e1824e58SKevin Wolf        if ! test -t 0; then
55e1824e58SKevin Wolf            while read cmd; do
56e1824e58SKevin Wolf                echo $cmd
57e1824e58SKevin Wolf            done
58e1824e58SKevin Wolf        fi
59e1824e58SKevin Wolf        echo quit
6005b4cd5dSKevin Wolf    ) | $QEMU -S -display none -device virtio-scsi-pci -monitor stdio "$@" 2>&1
61e1824e58SKevin Wolf    echo
62e1824e58SKevin Wolf}
63e1824e58SKevin Wolf
648cedcffdSEric Blakecheck_info_block()
65e1824e58SKevin Wolf{
66e1824e58SKevin Wolf    echo "info block" |
6705b4cd5dSKevin Wolf    do_run_qemu "$@" | _filter_win32 | _filter_hmp | _filter_qemu |
68627f607eSAlberto Garcia        _filter_generated_node_ids | _filter_qom_path
69e1824e58SKevin Wolf}
70e1824e58SKevin Wolf
71e1824e58SKevin Wolf
72e1824e58SKevin Wolfsize=64M
73e1824e58SKevin Wolf_make_test_img $size
74e1824e58SKevin Wolf
75e1824e58SKevin Wolfremovable="floppy ide-cd scsi-cd"
76e1824e58SKevin Wolffixed="ide-hd scsi-hd virtio-blk-pci"
77e1824e58SKevin Wolf
78e1824e58SKevin Wolfecho
79e1824e58SKevin Wolfecho "=== Empty drives ==="
80e1824e58SKevin Wolfecho
81e1824e58SKevin Wolf
82e1824e58SKevin Wolffor dev in $removable; do
83e1824e58SKevin Wolf    check_info_block -device $dev
84e1824e58SKevin Wolf    check_info_block -device $dev,id=qdev_id
85e1824e58SKevin Wolfdone
86e1824e58SKevin Wolf
87e1824e58SKevin Wolfecho
88e1824e58SKevin Wolfecho "=== -blockdev/-device=<node-name> ==="
89e1824e58SKevin Wolfecho
90e1824e58SKevin Wolf
91e1824e58SKevin Wolffor dev in $fixed $removable; do
92a6862418SAndrey Shinkevich    check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null
93a6862418SAndrey Shinkevich    check_info_block -blockdev driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
94e1824e58SKevin Wolfdone
95e1824e58SKevin Wolf
96e1824e58SKevin Wolfecho
97e1824e58SKevin Wolfecho "=== -drive if=none/-device=<node-name> ==="
98e1824e58SKevin Wolfecho
99e1824e58SKevin Wolf
100e1824e58SKevin Wolf# This creates two BlockBackends that will show up in 'info block'!
101e1824e58SKevin Wolf# A monitor-owned one from -drive, and anonymous one from -device
102e1824e58SKevin Wolffor dev in $fixed $removable; do
103a6862418SAndrey Shinkevich    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=null,id=qdev_id
104e1824e58SKevin Wolfdone
105e1824e58SKevin Wolf
106e1824e58SKevin Wolfecho
107e1824e58SKevin Wolfecho "=== -drive if=none/-device=<bb-name> (with medium) ==="
108e1824e58SKevin Wolfecho
109e1824e58SKevin Wolf
110e1824e58SKevin Wolffor dev in $fixed $removable; do
111a6862418SAndrey Shinkevich    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0
112a6862418SAndrey Shinkevich    check_info_block -drive if=none,driver=null-co,read-zeroes=on,node-name=null -device $dev,drive=none0,id=qdev_id
113e1824e58SKevin Wolfdone
114e1824e58SKevin Wolf
115e1824e58SKevin Wolfecho
116e1824e58SKevin Wolfecho "=== -drive if=none/-device=<bb-name> (without medium) ==="
117e1824e58SKevin Wolfecho
118e1824e58SKevin Wolf
119e1824e58SKevin Wolfcheck_info_block -drive if=none
120e1824e58SKevin Wolf
121e1824e58SKevin Wolffor dev in $removable; do
122e1824e58SKevin Wolf    check_info_block -drive if=none -device $dev,drive=none0
123e1824e58SKevin Wolf    check_info_block -drive if=none -device $dev,drive=none0,id=qdev_id
124e1824e58SKevin Wolfdone
125e1824e58SKevin Wolf
126e1824e58SKevin Wolfecho
127e1824e58SKevin Wolfecho "=== -drive if=... ==="
128e1824e58SKevin Wolfecho
129e1824e58SKevin Wolf
130e1824e58SKevin Wolfcheck_info_block -drive if=floppy
131a6862418SAndrey Shinkevichcheck_info_block -drive if=floppy,driver=null-co,read-zeroes=on
132e1824e58SKevin Wolf
133a6862418SAndrey Shinkevichcheck_info_block -drive if=ide,driver=null-co,read-zeroes=on
134e1824e58SKevin Wolfcheck_info_block -drive if=ide,media=cdrom
135a6862418SAndrey Shinkevichcheck_info_block -drive if=ide,driver=null-co,read-zeroes=on,media=cdrom
136e1824e58SKevin Wolf
137a6862418SAndrey Shinkevichcheck_info_block -drive if=virtio,driver=null-co,read-zeroes=on
138e1824e58SKevin Wolf
139a6862418SAndrey Shinkevichcheck_info_block -drive if=pflash,driver=null-co,read-zeroes=on,size=1M
140e1824e58SKevin Wolf
141e1824e58SKevin Wolf# success, all done
142e1824e58SKevin Wolfecho "*** done"
143e1824e58SKevin Wolfrm -f $seq.full
144e1824e58SKevin Wolfstatus=0
145