13778057dSKevin Wolf#!/bin/sh 23778057dSKevin Wolf# 33778057dSKevin Wolf# Combined test to grow the refcount table and test snapshots. 43778057dSKevin Wolf# 53778057dSKevin Wolf# Copyright (C) 2009 Red Hat, Inc. 63778057dSKevin Wolf# 73778057dSKevin Wolf# This program is free software; you can redistribute it and/or modify 83778057dSKevin Wolf# it under the terms of the GNU General Public License as published by 93778057dSKevin Wolf# the Free Software Foundation; either version 2 of the License, or 103778057dSKevin Wolf# (at your option) any later version. 113778057dSKevin Wolf# 123778057dSKevin Wolf# This program is distributed in the hope that it will be useful, 133778057dSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 143778057dSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 153778057dSKevin Wolf# GNU General Public License for more details. 163778057dSKevin Wolf# 173778057dSKevin Wolf# You should have received a copy of the GNU General Public License 183778057dSKevin Wolf# along with this program; if not, write to the Free Software 193778057dSKevin Wolf# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 203778057dSKevin Wolf# USA 213778057dSKevin Wolf# 223778057dSKevin Wolf 233778057dSKevin Wolf# creator 243778057dSKevin Wolfowner=kwolf@redhat.com 253778057dSKevin Wolf 263778057dSKevin Wolfseq=`basename $0` 273778057dSKevin Wolfecho "QA output created by $seq" 283778057dSKevin Wolf 293778057dSKevin Wolfhere=`pwd` 303778057dSKevin Wolftmp=/tmp/$$ 313778057dSKevin Wolfstatus=1 # failure is the default! 323778057dSKevin Wolf 333778057dSKevin Wolf_cleanup() 343778057dSKevin Wolf{ 35e021915aSChristoph Hellwig _cleanup_test_img 363778057dSKevin Wolf true 373778057dSKevin Wolf} 383778057dSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 393778057dSKevin Wolf 403778057dSKevin Wolf# get standard environment, filters and checks 413778057dSKevin Wolf. ./common.rc 423778057dSKevin Wolf. ./common.filter 433778057dSKevin Wolf 44*e76a8e89SChristoph Hellwig# actually any format that supports snapshots 453778057dSKevin Wolf_supported_fmt qcow2 463778057dSKevin Wolf_supported_os Linux 473778057dSKevin Wolf 483778057dSKevin Wolfecho 493778057dSKevin Wolfecho "creating image" 503778057dSKevin Wolf 513778057dSKevin Wolf# With 1k clusters a refcount block contains 512 clusters 523778057dSKevin Wolf# This makes 512k of the image file covered by a refcount block 533778057dSKevin Wolf# A refcount table that spans one clusters has 128 refcount 543778057dSKevin Wolf# tables which makes up 64M in the image file. 553778057dSKevin Wolf# 563778057dSKevin Wolf# We use a 36M image, so initially we can be sure that only one cluster is used 573778057dSKevin Wolf# for the refcount table. On the other hand this is big enough to cause a 583778057dSKevin Wolf# refcount table growth when rewriting the image after creating one snapshot. 593778057dSKevin Wolfsize=36M 603778057dSKevin Wolf_make_test_img -o cluster_size=1k $size 613778057dSKevin Wolf 623778057dSKevin Wolf# Create two snapshots which fill the image with two different patterns 633778057dSKevin Wolfecho "creating first snapshot" 643778057dSKevin Wolf$QEMU_IO -c "aio_write -P 123 0 $size" $TEST_IMG | _filter_qemu_io 653778057dSKevin Wolf$QEMU_IMG snapshot -c snap1 $TEST_IMG 663778057dSKevin Wolfecho "creating second snapshot" 673778057dSKevin Wolf$QEMU_IO -c "aio_write -P 165 0 $size" $TEST_IMG | _filter_qemu_io 683778057dSKevin Wolf$QEMU_IMG snapshot -c snap2 $TEST_IMG 693778057dSKevin Wolf 703778057dSKevin Wolf# Now check the pattern 713778057dSKevin Wolfecho "checking first snapshot" 723778057dSKevin Wolf$QEMU_IMG snapshot -a snap1 $TEST_IMG 733778057dSKevin Wolf$QEMU_IO -c "aio_read -P 123 0 $size" $TEST_IMG | _filter_qemu_io 743778057dSKevin Wolfecho "checking second snapshot" 753778057dSKevin Wolf$QEMU_IMG snapshot -a snap2 $TEST_IMG 763778057dSKevin Wolf$QEMU_IO -c "aio_read -P 165 0 $size" $TEST_IMG | _filter_qemu_io 773778057dSKevin Wolf 783778057dSKevin Wolfecho 793778057dSKevin Wolfecho "checking image for errors" 803778057dSKevin Wolf_check_test_img 813778057dSKevin Wolf 823778057dSKevin Wolf# success, all done 833778057dSKevin Wolfecho "*** done" 843778057dSKevin Wolfrm -f $seq.full 853778057dSKevin Wolfstatus=0 86