1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 240812d93SEric Blake# 340812d93SEric Blake# Test corner cases with unusual block geometries 440812d93SEric Blake# 5d6ac6e93SEric Blake# Copyright (C) 2016-2018 Red Hat, Inc. 640812d93SEric Blake# 740812d93SEric Blake# This program is free software; you can redistribute it and/or modify 840812d93SEric Blake# it under the terms of the GNU General Public License as published by 940812d93SEric Blake# the Free Software Foundation; either version 2 of the License, or 1040812d93SEric Blake# (at your option) any later version. 1140812d93SEric Blake# 1240812d93SEric Blake# This program is distributed in the hope that it will be useful, 1340812d93SEric Blake# but WITHOUT ANY WARRANTY; without even the implied warranty of 1440812d93SEric Blake# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1540812d93SEric Blake# GNU General Public License for more details. 1640812d93SEric Blake# 1740812d93SEric Blake# You should have received a copy of the GNU General Public License 1840812d93SEric Blake# along with this program. If not, see <http://www.gnu.org/licenses/>. 1940812d93SEric Blake# 2040812d93SEric Blake 2140812d93SEric Blake# creator 2240812d93SEric Blakeowner=eblake@redhat.com 2340812d93SEric Blake 2440812d93SEric Blakeseq=`basename $0` 2540812d93SEric Blakeecho "QA output created by $seq" 2640812d93SEric Blake 2740812d93SEric Blakestatus=1 # failure is the default! 2840812d93SEric Blake 2940812d93SEric Blake_cleanup() 3040812d93SEric Blake{ 3140812d93SEric Blake _cleanup_test_img 3240812d93SEric Blake} 3340812d93SEric Blaketrap "_cleanup; exit \$status" 0 1 2 3 15 3440812d93SEric Blake 3540812d93SEric Blake# get standard environment, filters and checks 3640812d93SEric Blake. ./common.rc 3740812d93SEric Blake. ./common.filter 3840812d93SEric Blake 39d6ac6e93SEric Blake# This test is runnable under compat=0.10; see test 204 for additional 40d6ac6e93SEric Blake# tests specific to compat=1.1. 41d6ac6e93SEric Blake 4240812d93SEric Blake_supported_fmt qcow2 4340812d93SEric Blake_supported_proto file 4440812d93SEric Blake 4540812d93SEric BlakeCLUSTER_SIZE=1M 4640812d93SEric Blakesize=128M 4740812d93SEric Blakeoptions=driver=blkdebug,image.driver=qcow2 4840812d93SEric Blake 4940812d93SEric Blakeecho 5040812d93SEric Blakeecho "== setting up files ==" 5140812d93SEric Blake 5240812d93SEric BlakeTEST_IMG="$TEST_IMG.base" _make_test_img $size 5340812d93SEric Blake$QEMU_IO -c "write -P 11 0 $size" "$TEST_IMG.base" | _filter_qemu_io 5440812d93SEric Blake_make_test_img -b "$TEST_IMG.base" 55d6ac6e93SEric Blake$QEMU_IO -c "write -P 22 0 $size" "$TEST_IMG" | _filter_qemu_io 5640812d93SEric Blake 5740812d93SEric Blake# Limited to 64k max-transfer 5840812d93SEric Blakeecho 5940812d93SEric Blakeecho "== constrained alignment and max-transfer ==" 6040812d93SEric Blakelimits=align=4k,max-transfer=64k 6140812d93SEric Blake$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ 6240812d93SEric Blake -c "write -P 33 1000 128k" -c "read -P 33 1000 128k" | _filter_qemu_io 6340812d93SEric Blake 6440812d93SEric Blakeecho 6540812d93SEric Blakeecho "== write zero with constrained max-transfer ==" 6640812d93SEric Blakelimits=align=512,max-transfer=64k,opt-write-zero=$CLUSTER_SIZE 6740812d93SEric Blake$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ 6840812d93SEric Blake -c "write -z 8003584 2093056" | _filter_qemu_io 6940812d93SEric Blake 7040812d93SEric Blake# non-power-of-2 write-zero/discard alignments 7140812d93SEric Blakeecho 7240812d93SEric Blakeecho "== non-power-of-2 write zeroes limits ==" 7340812d93SEric Blake 7440812d93SEric Blakelimits=align=512,opt-write-zero=15M,max-write-zero=15M,opt-discard=15M,max-discard=15M 7540812d93SEric Blake$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ 7640812d93SEric Blake -c "write -z 32M 32M" | _filter_qemu_io 7740812d93SEric Blake 7840812d93SEric Blakeecho 7940812d93SEric Blakeecho "== non-power-of-2 discard limits ==" 8040812d93SEric Blake 8140812d93SEric Blakelimits=align=512,opt-write-zero=15M,max-write-zero=15M,opt-discard=15M,max-discard=15M 8240812d93SEric Blake$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ 8340812d93SEric Blake -c "discard 80000001 30M" | _filter_qemu_io 8440812d93SEric Blake 8540812d93SEric Blakeecho 8640812d93SEric Blakeecho "== verify image content ==" 8740812d93SEric Blake 888cedcffdSEric Blakeverify_io() 8940812d93SEric Blake{ 9040812d93SEric Blake if ($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | 9140812d93SEric Blake grep "compat: 0.10" > /dev/null); then 9240812d93SEric Blake # For v2 images, discarded clusters are read from the backing file 9340812d93SEric Blake discarded=11 9440812d93SEric Blake else 9540812d93SEric Blake # Discarded clusters are zeroed for v3 or later 9640812d93SEric Blake discarded=0 9740812d93SEric Blake fi 9840812d93SEric Blake 9940812d93SEric Blake echo read -P 22 0 1000 10040812d93SEric Blake echo read -P 33 1000 128k 10140812d93SEric Blake echo read -P 22 132072 7871512 10240812d93SEric Blake echo read -P 0 8003584 2093056 10340812d93SEric Blake echo read -P 22 10096640 23457792 10440812d93SEric Blake echo read -P 0 32M 32M 10540812d93SEric Blake echo read -P 22 64M 13M 10640812d93SEric Blake echo read -P $discarded 77M 29M 107d6ac6e93SEric Blake echo read -P 22 106M 22M 10840812d93SEric Blake} 10940812d93SEric Blake 11040812d93SEric Blakeverify_io | $QEMU_IO -r "$TEST_IMG" | _filter_qemu_io 11140812d93SEric Blake 11240812d93SEric Blake_check_test_img 11340812d93SEric Blake 11440812d93SEric Blake# success, all done 11540812d93SEric Blakeecho "*** done" 11640812d93SEric Blakestatus=0 117