xref: /openbmc/qemu/tests/qemu-iotests/227 (revision 5107022a616247216a7f7338bd7c62b4399d89eb)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir 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
43*d9e40706SThomas Huth_require_devices virtio-blk
44*d9e40706SThomas Huth
458cedcffdSEric Blakedo_run_qemu()
461239ac24SKevin Wolf{
471239ac24SKevin Wolf    echo Testing: "$@"
481239ac24SKevin Wolf    $QEMU -nographic -qmp-pretty stdio -serial none "$@"
491239ac24SKevin Wolf    echo
501239ac24SKevin Wolf}
511239ac24SKevin Wolf
528cedcffdSEric Blakerun_qemu()
531239ac24SKevin Wolf{
541239ac24SKevin Wolf    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
551239ac24SKevin Wolf                          | _filter_qemu | _filter_imgfmt \
561239ac24SKevin Wolf                          | _filter_generated_node_ids
571239ac24SKevin Wolf}
581239ac24SKevin Wolf
591239ac24SKevin Wolfecho
601239ac24SKevin Wolfecho '=== blockstats with -drive if=virtio ==='
611239ac24SKevin Wolfecho
621239ac24SKevin Wolf
63a6862418SAndrey Shinkevichrun_qemu -drive driver=null-co,read-zeroes=on,if=virtio <<EOF
641239ac24SKevin Wolf{ "execute": "qmp_capabilities" }
651239ac24SKevin Wolf{ "execute": "query-blockstats"}
661239ac24SKevin Wolf{ "execute": "quit" }
671239ac24SKevin WolfEOF
681239ac24SKevin Wolf
691239ac24SKevin Wolfecho
701239ac24SKevin Wolfecho '=== blockstats with -drive if=none ==='
711239ac24SKevin Wolfecho
721239ac24SKevin Wolf
731239ac24SKevin Wolfrun_qemu -drive driver=null-co,if=none <<EOF
741239ac24SKevin Wolf{ "execute": "qmp_capabilities" }
751239ac24SKevin Wolf{ "execute": "query-blockstats"}
761239ac24SKevin Wolf{ "execute": "quit" }
771239ac24SKevin WolfEOF
781239ac24SKevin Wolf
791239ac24SKevin Wolfecho
801239ac24SKevin Wolfecho '=== blockstats with -blockdev ==='
811239ac24SKevin Wolfecho
821239ac24SKevin Wolf
831239ac24SKevin Wolfrun_qemu -blockdev driver=null-co,node-name=null <<EOF
841239ac24SKevin Wolf{ "execute": "qmp_capabilities" }
851239ac24SKevin Wolf{ "execute": "query-blockstats"}
861239ac24SKevin Wolf{ "execute": "quit" }
871239ac24SKevin WolfEOF
881239ac24SKevin Wolf
891239ac24SKevin Wolfecho
901239ac24SKevin Wolfecho '=== blockstats with -blockdev and -device ==='
911239ac24SKevin Wolfecho
921239ac24SKevin Wolf
93a6862418SAndrey Shinkevichrun_qemu -blockdev driver=null-co,read-zeroes=on,node-name=null -device virtio-blk,drive=null,id=virtio0 <<EOF
941239ac24SKevin Wolf{ "execute": "qmp_capabilities" }
951239ac24SKevin Wolf{ "execute": "query-blockstats"}
961239ac24SKevin Wolf{ "execute": "quit" }
971239ac24SKevin WolfEOF
981239ac24SKevin Wolf
991239ac24SKevin Wolf# success, all done
1001239ac24SKevin Wolfecho "*** done"
1011239ac24SKevin Wolfrm -f $seq.full
1021239ac24SKevin Wolfstatus=0
103