xref: /openbmc/qemu/tests/qemu-iotests/227 (revision 0e324626)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2*9dd003a9SVladimir Sementsov-Ogievskiy# group: quick
31239ac24SKevin Wolf#
41239ac24SKevin Wolf# Test query-blockstats with different ways to create a BB
51239ac24SKevin Wolf#
61239ac24SKevin Wolf# Copyright (C) 2018 Red Hat, Inc.
71239ac24SKevin Wolf#
81239ac24SKevin Wolf# This program is free software; you can redistribute it and/or modify
91239ac24SKevin Wolf# it under the terms of the GNU General Public License as published by
101239ac24SKevin Wolf# the Free Software Foundation; either version 2 of the License, or
111239ac24SKevin Wolf# (at your option) any later version.
121239ac24SKevin Wolf#
131239ac24SKevin Wolf# This program is distributed in the hope that it will be useful,
141239ac24SKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
151239ac24SKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
161239ac24SKevin Wolf# GNU General Public License for more details.
171239ac24SKevin Wolf#
181239ac24SKevin Wolf# You should have received a copy of the GNU General Public License
191239ac24SKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
201239ac24SKevin Wolf#
211239ac24SKevin Wolf
221239ac24SKevin Wolf# creator
231239ac24SKevin Wolfowner=kwolf@redhat.com
241239ac24SKevin Wolf
251239ac24SKevin Wolfseq=$(basename $0)
261239ac24SKevin Wolfecho "QA output created by $seq"
271239ac24SKevin Wolf
281239ac24SKevin Wolfstatus=1	# failure is the default!
291239ac24SKevin Wolf
301239ac24SKevin Wolf_cleanup()
311239ac24SKevin Wolf{
321239ac24SKevin Wolf    _cleanup_test_img
331239ac24SKevin Wolf}
341239ac24SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
351239ac24SKevin Wolf
361239ac24SKevin Wolf# get standard environment, filters and checks
371239ac24SKevin Wolf. ./common.rc
381239ac24SKevin Wolf. ./common.filter
391239ac24SKevin Wolf
401239ac24SKevin Wolf_supported_fmt generic
411239ac24SKevin Wolf_supported_proto file
421239ac24SKevin Wolf
438cedcffdSEric Blakedo_run_qemu()
441239ac24SKevin Wolf{
451239ac24SKevin Wolf    echo Testing: "$@"
461239ac24SKevin Wolf    $QEMU -nographic -qmp-pretty stdio -serial none "$@"
471239ac24SKevin Wolf    echo
481239ac24SKevin Wolf}
491239ac24SKevin Wolf
508cedcffdSEric Blakerun_qemu()
511239ac24SKevin Wolf{
521239ac24SKevin Wolf    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
531239ac24SKevin Wolf                          | _filter_qemu | _filter_imgfmt \
541239ac24SKevin Wolf                          | _filter_generated_node_ids
551239ac24SKevin Wolf}
561239ac24SKevin Wolf
571239ac24SKevin Wolfecho
581239ac24SKevin Wolfecho '=== blockstats with -drive if=virtio ==='
591239ac24SKevin Wolfecho
601239ac24SKevin Wolf
61a6862418SAndrey Shinkevichrun_qemu -drive driver=null-co,read-zeroes=on,if=virtio <<EOF
621239ac24SKevin Wolf{ "execute": "qmp_capabilities" }
631239ac24SKevin Wolf{ "execute": "query-blockstats"}
641239ac24SKevin Wolf{ "execute": "quit" }
651239ac24SKevin WolfEOF
661239ac24SKevin Wolf
671239ac24SKevin Wolfecho
681239ac24SKevin Wolfecho '=== blockstats with -drive if=none ==='
691239ac24SKevin Wolfecho
701239ac24SKevin Wolf
711239ac24SKevin Wolfrun_qemu -drive driver=null-co,if=none <<EOF
721239ac24SKevin Wolf{ "execute": "qmp_capabilities" }
731239ac24SKevin Wolf{ "execute": "query-blockstats"}
741239ac24SKevin Wolf{ "execute": "quit" }
751239ac24SKevin WolfEOF
761239ac24SKevin Wolf
771239ac24SKevin Wolfecho
781239ac24SKevin Wolfecho '=== blockstats with -blockdev ==='
791239ac24SKevin Wolfecho
801239ac24SKevin Wolf
811239ac24SKevin Wolfrun_qemu -blockdev driver=null-co,node-name=null <<EOF
821239ac24SKevin Wolf{ "execute": "qmp_capabilities" }
831239ac24SKevin Wolf{ "execute": "query-blockstats"}
841239ac24SKevin Wolf{ "execute": "quit" }
851239ac24SKevin WolfEOF
861239ac24SKevin Wolf
871239ac24SKevin Wolfecho
881239ac24SKevin Wolfecho '=== blockstats with -blockdev and -device ==='
891239ac24SKevin Wolfecho
901239ac24SKevin Wolf
91a6862418SAndrey Shinkevichrun_qemu -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-blk,drive=null,id=virtio0 <<EOF
921239ac24SKevin Wolf{ "execute": "qmp_capabilities" }
931239ac24SKevin Wolf{ "execute": "query-blockstats"}
941239ac24SKevin Wolf{ "execute": "quit" }
951239ac24SKevin WolfEOF
961239ac24SKevin Wolf
971239ac24SKevin Wolf# success, all done
981239ac24SKevin Wolfecho "*** done"
991239ac24SKevin Wolfrm -f $seq.full
1001239ac24SKevin Wolfstatus=0
101