1*3778057dSKevin Wolf#!/bin/sh 2*3778057dSKevin Wolf# 3*3778057dSKevin Wolf# Combined test to grow the refcount table and test snapshots. 4*3778057dSKevin Wolf# 5*3778057dSKevin Wolf# Copyright (C) 2009 Red Hat, Inc. 6*3778057dSKevin Wolf# 7*3778057dSKevin Wolf# This program is free software; you can redistribute it and/or modify 8*3778057dSKevin Wolf# it under the terms of the GNU General Public License as published by 9*3778057dSKevin Wolf# the Free Software Foundation; either version 2 of the License, or 10*3778057dSKevin Wolf# (at your option) any later version. 11*3778057dSKevin Wolf# 12*3778057dSKevin Wolf# This program is distributed in the hope that it will be useful, 13*3778057dSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 14*3778057dSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*3778057dSKevin Wolf# GNU General Public License for more details. 16*3778057dSKevin Wolf# 17*3778057dSKevin Wolf# You should have received a copy of the GNU General Public License 18*3778057dSKevin Wolf# along with this program; if not, write to the Free Software 19*3778057dSKevin Wolf# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20*3778057dSKevin Wolf# USA 21*3778057dSKevin Wolf# 22*3778057dSKevin Wolf 23*3778057dSKevin Wolf# creator 24*3778057dSKevin Wolfowner=kwolf@redhat.com 25*3778057dSKevin Wolf 26*3778057dSKevin Wolfseq=`basename $0` 27*3778057dSKevin Wolfecho "QA output created by $seq" 28*3778057dSKevin Wolf 29*3778057dSKevin Wolfhere=`pwd` 30*3778057dSKevin Wolftmp=/tmp/$$ 31*3778057dSKevin Wolfstatus=1 # failure is the default! 32*3778057dSKevin Wolf 33*3778057dSKevin Wolf_cleanup() 34*3778057dSKevin Wolf{ 35*3778057dSKevin Wolf# _cleanup_test_img 36*3778057dSKevin Wolf true 37*3778057dSKevin Wolf} 38*3778057dSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 39*3778057dSKevin Wolf 40*3778057dSKevin Wolf# get standard environment, filters and checks 41*3778057dSKevin Wolf. ./common.rc 42*3778057dSKevin Wolf. ./common.filter 43*3778057dSKevin Wolf 44*3778057dSKevin Wolf# currently only qcow2 allows for consistency checks using qemu-img 45*3778057dSKevin Wolf_supported_fmt qcow2 46*3778057dSKevin Wolf_supported_os Linux 47*3778057dSKevin Wolf 48*3778057dSKevin Wolfecho 49*3778057dSKevin Wolfecho "creating image" 50*3778057dSKevin Wolf 51*3778057dSKevin Wolf# With 1k clusters a refcount block contains 512 clusters 52*3778057dSKevin Wolf# This makes 512k of the image file covered by a refcount block 53*3778057dSKevin Wolf# A refcount table that spans one clusters has 128 refcount 54*3778057dSKevin Wolf# tables which makes up 64M in the image file. 55*3778057dSKevin Wolf# 56*3778057dSKevin Wolf# We use a 36M image, so initially we can be sure that only one cluster is used 57*3778057dSKevin Wolf# for the refcount table. On the other hand this is big enough to cause a 58*3778057dSKevin Wolf# refcount table growth when rewriting the image after creating one snapshot. 59*3778057dSKevin Wolfsize=36M 60*3778057dSKevin Wolf_make_test_img -o cluster_size=1k $size 61*3778057dSKevin Wolf 62*3778057dSKevin Wolf# Create two snapshots which fill the image with two different patterns 63*3778057dSKevin Wolfecho "creating first snapshot" 64*3778057dSKevin Wolf$QEMU_IO -c "aio_write -P 123 0 $size" $TEST_IMG | _filter_qemu_io 65*3778057dSKevin Wolf$QEMU_IMG snapshot -c snap1 $TEST_IMG 66*3778057dSKevin Wolfecho "creating second snapshot" 67*3778057dSKevin Wolf$QEMU_IO -c "aio_write -P 165 0 $size" $TEST_IMG | _filter_qemu_io 68*3778057dSKevin Wolf$QEMU_IMG snapshot -c snap2 $TEST_IMG 69*3778057dSKevin Wolf 70*3778057dSKevin Wolf# Now check the pattern 71*3778057dSKevin Wolfecho "checking first snapshot" 72*3778057dSKevin Wolf$QEMU_IMG snapshot -a snap1 $TEST_IMG 73*3778057dSKevin Wolf$QEMU_IO -c "aio_read -P 123 0 $size" $TEST_IMG | _filter_qemu_io 74*3778057dSKevin Wolfecho "checking second snapshot" 75*3778057dSKevin Wolf$QEMU_IMG snapshot -a snap2 $TEST_IMG 76*3778057dSKevin Wolf$QEMU_IO -c "aio_read -P 165 0 $size" $TEST_IMG | _filter_qemu_io 77*3778057dSKevin Wolf 78*3778057dSKevin Wolfecho 79*3778057dSKevin Wolfecho "checking image for errors" 80*3778057dSKevin Wolf_check_test_img 81*3778057dSKevin Wolf 82*3778057dSKevin Wolf# success, all done 83*3778057dSKevin Wolfecho "*** done" 84*3778057dSKevin Wolfrm -f $seq.full 85*3778057dSKevin Wolfstatus=0 86