1*1239ac24SKevin Wolf#!/bin/bash 2*1239ac24SKevin Wolf# 3*1239ac24SKevin Wolf# Test query-blockstats with different ways to create a BB 4*1239ac24SKevin Wolf# 5*1239ac24SKevin Wolf# Copyright (C) 2018 Red Hat, Inc. 6*1239ac24SKevin Wolf# 7*1239ac24SKevin Wolf# This program is free software; you can redistribute it and/or modify 8*1239ac24SKevin Wolf# it under the terms of the GNU General Public License as published by 9*1239ac24SKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10*1239ac24SKevin Wolf# (at your option) any later version. 11*1239ac24SKevin Wolf# 12*1239ac24SKevin Wolf# This program is distributed in the hope that it will be useful, 13*1239ac24SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*1239ac24SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*1239ac24SKevin Wolf# GNU General Public License for more details. 16*1239ac24SKevin Wolf# 17*1239ac24SKevin Wolf# You should have received a copy of the GNU General Public License 18*1239ac24SKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*1239ac24SKevin Wolf# 20*1239ac24SKevin Wolf 21*1239ac24SKevin Wolf# creator 22*1239ac24SKevin Wolfowner=kwolf@redhat.com 23*1239ac24SKevin Wolf 24*1239ac24SKevin Wolfseq=$(basename $0) 25*1239ac24SKevin Wolfecho "QA output created by $seq" 26*1239ac24SKevin Wolf 27*1239ac24SKevin Wolfhere=$PWD 28*1239ac24SKevin Wolfstatus=1 # failure is the default! 29*1239ac24SKevin Wolf 30*1239ac24SKevin Wolf_cleanup() 31*1239ac24SKevin Wolf{ 32*1239ac24SKevin Wolf _cleanup_test_img 33*1239ac24SKevin Wolf} 34*1239ac24SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 35*1239ac24SKevin Wolf 36*1239ac24SKevin Wolf# get standard environment, filters and checks 37*1239ac24SKevin Wolf. ./common.rc 38*1239ac24SKevin Wolf. ./common.filter 39*1239ac24SKevin Wolf 40*1239ac24SKevin Wolf_supported_fmt generic 41*1239ac24SKevin Wolf_supported_proto file 42*1239ac24SKevin Wolf_supported_os Linux 43*1239ac24SKevin Wolf 44*1239ac24SKevin Wolffunction do_run_qemu() 45*1239ac24SKevin Wolf{ 46*1239ac24SKevin Wolf echo Testing: "$@" 47*1239ac24SKevin Wolf $QEMU -nographic -qmp-pretty stdio -serial none "$@" 48*1239ac24SKevin Wolf echo 49*1239ac24SKevin Wolf} 50*1239ac24SKevin Wolf 51*1239ac24SKevin Wolffunction run_qemu() 52*1239ac24SKevin Wolf{ 53*1239ac24SKevin Wolf do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \ 54*1239ac24SKevin Wolf | _filter_qemu | _filter_imgfmt \ 55*1239ac24SKevin Wolf | _filter_generated_node_ids 56*1239ac24SKevin Wolf} 57*1239ac24SKevin Wolf 58*1239ac24SKevin Wolfecho 59*1239ac24SKevin Wolfecho '=== blockstats with -drive if=virtio ===' 60*1239ac24SKevin Wolfecho 61*1239ac24SKevin Wolf 62*1239ac24SKevin Wolfrun_qemu -drive driver=null-co,if=virtio <<EOF 63*1239ac24SKevin Wolf{ "execute": "qmp_capabilities" } 64*1239ac24SKevin Wolf{ "execute": "query-blockstats"} 65*1239ac24SKevin Wolf{ "execute": "quit" } 66*1239ac24SKevin WolfEOF 67*1239ac24SKevin Wolf 68*1239ac24SKevin Wolfecho 69*1239ac24SKevin Wolfecho '=== blockstats with -drive if=none ===' 70*1239ac24SKevin Wolfecho 71*1239ac24SKevin Wolf 72*1239ac24SKevin Wolfrun_qemu -drive driver=null-co,if=none <<EOF 73*1239ac24SKevin Wolf{ "execute": "qmp_capabilities" } 74*1239ac24SKevin Wolf{ "execute": "query-blockstats"} 75*1239ac24SKevin Wolf{ "execute": "quit" } 76*1239ac24SKevin WolfEOF 77*1239ac24SKevin Wolf 78*1239ac24SKevin Wolfecho 79*1239ac24SKevin Wolfecho '=== blockstats with -blockdev ===' 80*1239ac24SKevin Wolfecho 81*1239ac24SKevin Wolf 82*1239ac24SKevin Wolfrun_qemu -blockdev driver=null-co,node-name=null <<EOF 83*1239ac24SKevin Wolf{ "execute": "qmp_capabilities" } 84*1239ac24SKevin Wolf{ "execute": "query-blockstats"} 85*1239ac24SKevin Wolf{ "execute": "quit" } 86*1239ac24SKevin WolfEOF 87*1239ac24SKevin Wolf 88*1239ac24SKevin Wolfecho 89*1239ac24SKevin Wolfecho '=== blockstats with -blockdev and -device ===' 90*1239ac24SKevin Wolfecho 91*1239ac24SKevin Wolf 92*1239ac24SKevin Wolfrun_qemu -blockdev driver=null-co,node-name=null -device virtio-blk,drive=null,id=virtio0 <<EOF 93*1239ac24SKevin Wolf{ "execute": "qmp_capabilities" } 94*1239ac24SKevin Wolf{ "execute": "query-blockstats"} 95*1239ac24SKevin Wolf{ "execute": "quit" } 96*1239ac24SKevin WolfEOF 97*1239ac24SKevin Wolf 98*1239ac24SKevin Wolf# success, all done 99*1239ac24SKevin Wolfecho "*** done" 100*1239ac24SKevin Wolfrm -f $seq.full 101*1239ac24SKevin Wolfstatus=0 102