1*52280eacSKevin Wolf#!/bin/bash 2*52280eacSKevin Wolf# 3*52280eacSKevin Wolf# qcow2 error path testing 4*52280eacSKevin Wolf# 5*52280eacSKevin Wolf# Copyright (C) 2010 Red Hat, Inc. 6*52280eacSKevin Wolf# 7*52280eacSKevin Wolf# This program is free software; you can redistribute it and/or modify 8*52280eacSKevin Wolf# it under the terms of the GNU General Public License as published by 9*52280eacSKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10*52280eacSKevin Wolf# (at your option) any later version. 11*52280eacSKevin Wolf# 12*52280eacSKevin Wolf# This program is distributed in the hope that it will be useful, 13*52280eacSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*52280eacSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*52280eacSKevin Wolf# GNU General Public License for more details. 16*52280eacSKevin Wolf# 17*52280eacSKevin Wolf# You should have received a copy of the GNU General Public License 18*52280eacSKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*52280eacSKevin Wolf# 20*52280eacSKevin Wolf 21*52280eacSKevin Wolf# creator 22*52280eacSKevin Wolfowner=kwolf@redhat.com 23*52280eacSKevin Wolf 24*52280eacSKevin Wolfseq=`basename $0` 25*52280eacSKevin Wolfecho "QA output created by $seq" 26*52280eacSKevin Wolf 27*52280eacSKevin Wolfhere=`pwd` 28*52280eacSKevin Wolftmp=/tmp/$$ 29*52280eacSKevin Wolfstatus=1 # failure is the default! 30*52280eacSKevin Wolf 31*52280eacSKevin Wolf_cleanup() 32*52280eacSKevin Wolf{ 33*52280eacSKevin Wolf _cleanup_test_img 34*52280eacSKevin Wolf rm $TEST_DIR/blkdebug.conf 35*52280eacSKevin Wolf} 36*52280eacSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 37*52280eacSKevin Wolf 38*52280eacSKevin Wolf# get standard environment, filters and checks 39*52280eacSKevin Wolf. ./common.rc 40*52280eacSKevin Wolf. ./common.filter 41*52280eacSKevin Wolf. ./common.pattern 42*52280eacSKevin Wolf 43*52280eacSKevin Wolf# Currently only qcow2 supports rebasing 44*52280eacSKevin Wolf_supported_fmt qcow2 45*52280eacSKevin Wolf_supported_os Linux 46*52280eacSKevin Wolf 47*52280eacSKevin Wolf 48*52280eacSKevin Wolfecho "Errors while writing 128 kB" 49*52280eacSKevin Wolfecho 50*52280eacSKevin Wolf 51*52280eacSKevin WolfCLUSTER_SIZE=1024 52*52280eacSKevin Wolf 53*52280eacSKevin WolfBLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" 54*52280eacSKevin Wolf 55*52280eacSKevin Wolffor event in \ 56*52280eacSKevin Wolf l1_update \ 57*52280eacSKevin Wolf \ 58*52280eacSKevin Wolf l2_load \ 59*52280eacSKevin Wolf l2_update \ 60*52280eacSKevin Wolf l2_alloc.write \ 61*52280eacSKevin Wolf \ 62*52280eacSKevin Wolf write_aio \ 63*52280eacSKevin Wolf \ 64*52280eacSKevin Wolf refblock_load \ 65*52280eacSKevin Wolf refblock_update_part \ 66*52280eacSKevin Wolf refblock_alloc \ 67*52280eacSKevin Wolf \ 68*52280eacSKevin Wolf cluster_alloc \ 69*52280eacSKevin Wolf 70*52280eacSKevin Wolfdo 71*52280eacSKevin Wolf 72*52280eacSKevin Wolffor errno in 5 28; do 73*52280eacSKevin Wolffor imm in off; do 74*52280eacSKevin Wolffor once in on off; do 75*52280eacSKevin Wolffor vmstate in "" "-b"; do 76*52280eacSKevin Wolf 77*52280eacSKevin Wolfcat > $TEST_DIR/blkdebug.conf <<EOF 78*52280eacSKevin Wolf[inject-error] 79*52280eacSKevin Wolfevent = "$event" 80*52280eacSKevin Wolferrno = "$errno" 81*52280eacSKevin Wolfimmediately = "$imm" 82*52280eacSKevin Wolfonce ="$once" 83*52280eacSKevin WolfEOF 84*52280eacSKevin Wolf 85*52280eacSKevin Wolf_make_test_img 1G 86*52280eacSKevin Wolf 87*52280eacSKevin Wolfecho 88*52280eacSKevin Wolfecho "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate" 89*52280eacSKevin Wolf$QEMU_IO -c "write $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io 90*52280eacSKevin Wolf 91*52280eacSKevin Wolf# l2_load is not called on allocation, so issue a second write 92*52280eacSKevin Wolf# Reads are another path to trigger l2_load, so do a read, too 93*52280eacSKevin Wolfif [ "$event" == "l2_load" ]; then 94*52280eacSKevin Wolf $QEMU_IO -c "write $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io 95*52280eacSKevin Wolf $QEMU_IO -c "read $vmstate 0 128k " $BLKDBG_TEST_IMG | _filter_qemu_io 96*52280eacSKevin Wolffi 97*52280eacSKevin Wolf 98*52280eacSKevin Wolf$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" 99*52280eacSKevin Wolf 100*52280eacSKevin Wolfdone 101*52280eacSKevin Wolfdone 102*52280eacSKevin Wolfdone 103*52280eacSKevin Wolfdone 104*52280eacSKevin Wolfdone 105*52280eacSKevin Wolf 106*52280eacSKevin Wolf 107*52280eacSKevin Wolfecho 108*52280eacSKevin Wolfecho === Refcout table growth tests === 109*52280eacSKevin Wolfecho 110*52280eacSKevin WolfCLUSTER_SIZE=512 111*52280eacSKevin Wolf 112*52280eacSKevin Wolf 113*52280eacSKevin Wolffor event in \ 114*52280eacSKevin Wolf refblock_alloc.hookup \ 115*52280eacSKevin Wolf refblock_alloc.write \ 116*52280eacSKevin Wolf refblock_alloc.write_blocks \ 117*52280eacSKevin Wolf refblock_alloc.write_table \ 118*52280eacSKevin Wolf refblock_alloc.switch_table \ 119*52280eacSKevin Wolf 120*52280eacSKevin Wolfdo 121*52280eacSKevin Wolf 122*52280eacSKevin Wolf# This one takes a while, so let's test only one error code (ENOSPC should 123*52280eacSKevin Wolf# never be generated by qemu, so it's probably a good choice) 124*52280eacSKevin Wolffor errno in 28; do 125*52280eacSKevin Wolffor imm in off; do 126*52280eacSKevin Wolffor once in on off; do 127*52280eacSKevin Wolffor vmstate in "" "-b"; do 128*52280eacSKevin Wolf 129*52280eacSKevin Wolfcat > $TEST_DIR/blkdebug.conf <<EOF 130*52280eacSKevin Wolf[inject-error] 131*52280eacSKevin Wolfevent = "$event" 132*52280eacSKevin Wolferrno = "$errno" 133*52280eacSKevin Wolfimmediately = "$imm" 134*52280eacSKevin Wolfonce = "$once" 135*52280eacSKevin WolfEOF 136*52280eacSKevin Wolf 137*52280eacSKevin Wolf_make_test_img 1G 138*52280eacSKevin Wolf 139*52280eacSKevin Wolfecho 140*52280eacSKevin Wolfecho "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate" 141*52280eacSKevin Wolf$QEMU_IO -c "write $vmstate 0 64M" $BLKDBG_TEST_IMG | _filter_qemu_io 142*52280eacSKevin Wolf 143*52280eacSKevin Wolf$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" 144*52280eacSKevin Wolf 145*52280eacSKevin Wolfdone 146*52280eacSKevin Wolfdone 147*52280eacSKevin Wolfdone 148*52280eacSKevin Wolfdone 149*52280eacSKevin Wolfdone 150*52280eacSKevin Wolf 151*52280eacSKevin Wolfecho 152*52280eacSKevin Wolfecho === L1 growth tests === 153*52280eacSKevin Wolfecho 154*52280eacSKevin WolfCLUSTER_SIZE=1024 155*52280eacSKevin Wolf 156*52280eacSKevin Wolf 157*52280eacSKevin Wolffor event in \ 158*52280eacSKevin Wolf l1_grow.alloc_table \ 159*52280eacSKevin Wolf l1_grow.write_table \ 160*52280eacSKevin Wolf l1_grow.activate_table \ 161*52280eacSKevin Wolf 162*52280eacSKevin Wolfdo 163*52280eacSKevin Wolf 164*52280eacSKevin Wolffor errno in 5 28; do 165*52280eacSKevin Wolffor imm in off; do 166*52280eacSKevin Wolffor once in on off; do 167*52280eacSKevin Wolf 168*52280eacSKevin Wolfcat > $TEST_DIR/blkdebug.conf <<EOF 169*52280eacSKevin Wolf[inject-error] 170*52280eacSKevin Wolfevent = "$event" 171*52280eacSKevin Wolferrno = "$errno" 172*52280eacSKevin Wolfimmediately = "$imm" 173*52280eacSKevin Wolfonce = "$once" 174*52280eacSKevin WolfEOF 175*52280eacSKevin Wolf 176*52280eacSKevin Wolf_make_test_img 1G 177*52280eacSKevin Wolf 178*52280eacSKevin Wolfecho 179*52280eacSKevin Wolfecho "Event: $event; errno: $errno; imm: $imm; once: $once" 180*52280eacSKevin Wolf$QEMU_IO -c "write -b 0 64k" $BLKDBG_TEST_IMG | _filter_qemu_io 181*52280eacSKevin Wolf 182*52280eacSKevin Wolf$QEMU_IMG check $TEST_IMG 2>&1 | grep -v "refcount=1 reference=0" 183*52280eacSKevin Wolf 184*52280eacSKevin Wolfdone 185*52280eacSKevin Wolfdone 186*52280eacSKevin Wolfdone 187*52280eacSKevin Wolfdone 188*52280eacSKevin Wolf 189*52280eacSKevin Wolf# success, all done 190*52280eacSKevin Wolfecho "*** done" 191*52280eacSKevin Wolfrm -f $seq.full 192*52280eacSKevin Wolfstatus=0 193