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