1*975a93c0SMax Reitz#!/bin/bash 2*975a93c0SMax Reitz# 3*975a93c0SMax Reitz# Test case for discarding preallocated zero clusters in qcow2 4*975a93c0SMax Reitz# 5*975a93c0SMax Reitz# Copyright (C) 2013 Red Hat, Inc. 6*975a93c0SMax Reitz# 7*975a93c0SMax Reitz# This program is free software; you can redistribute it and/or modify 8*975a93c0SMax Reitz# it under the terms of the GNU General Public License as published by 9*975a93c0SMax Reitz# the Free Software Foundation; either version 2 of the License, or 10*975a93c0SMax Reitz# (at your option) any later version. 11*975a93c0SMax Reitz# 12*975a93c0SMax Reitz# This program is distributed in the hope that it will be useful, 13*975a93c0SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*975a93c0SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*975a93c0SMax Reitz# GNU General Public License for more details. 16*975a93c0SMax Reitz# 17*975a93c0SMax Reitz# You should have received a copy of the GNU General Public License 18*975a93c0SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 19*975a93c0SMax Reitz# 20*975a93c0SMax Reitz 21*975a93c0SMax Reitz# creator 22*975a93c0SMax Reitzowner=mreitz@redhat.com 23*975a93c0SMax Reitz 24*975a93c0SMax Reitzseq="$(basename $0)" 25*975a93c0SMax Reitzecho "QA output created by $seq" 26*975a93c0SMax Reitz 27*975a93c0SMax Reitzhere="$PWD" 28*975a93c0SMax Reitztmp=/tmp/$$ 29*975a93c0SMax Reitzstatus=1 # failure is the default! 30*975a93c0SMax Reitz 31*975a93c0SMax Reitz_cleanup() 32*975a93c0SMax Reitz{ 33*975a93c0SMax Reitz _cleanup_test_img 34*975a93c0SMax Reitz} 35*975a93c0SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 36*975a93c0SMax Reitz 37*975a93c0SMax Reitz# get standard environment, filters and checks 38*975a93c0SMax Reitz. ./common.rc 39*975a93c0SMax Reitz. ./common.filter 40*975a93c0SMax Reitz 41*975a93c0SMax Reitz# This tests qocw2-specific low-level functionality 42*975a93c0SMax Reitz_supported_fmt qcow2 43*975a93c0SMax Reitz_supported_proto generic 44*975a93c0SMax Reitz_supported_os Linux 45*975a93c0SMax Reitz 46*975a93c0SMax ReitzIMGOPTS="compat=1.1" 47*975a93c0SMax ReitzIMG_SIZE=64M 48*975a93c0SMax Reitz 49*975a93c0SMax Reitzecho 50*975a93c0SMax Reitzecho "=== Testing snapshotting an image with zero clusters ===" 51*975a93c0SMax Reitzecho 52*975a93c0SMax Reitz_make_test_img $IMG_SIZE 53*975a93c0SMax Reitz# Write some normal clusters, zero them (creating preallocated zero clusters) 54*975a93c0SMax Reitz# and discard those 55*975a93c0SMax Reitz$QEMU_IO -c "write 0 256k" -c "write -z 0 256k" -c "discard 0 256k" "$TEST_IMG" \ 56*975a93c0SMax Reitz | _filter_qemu_io 57*975a93c0SMax Reitz# Check the image (there shouldn't be any leaks) 58*975a93c0SMax Reitz_check_test_img 59*975a93c0SMax Reitz 60*975a93c0SMax Reitz# success, all done 61*975a93c0SMax Reitzecho "*** done" 62*975a93c0SMax Reitzrm -f $seq.full 63*975a93c0SMax Reitzstatus=0 64