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