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