111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2*9dd003a9SVladimir Sementsov-Ogievskiy# group: snapshot auto 36bf19c94SChristoph Hellwig# 46bf19c94SChristoph Hellwig# Check for one possible case of qcow2 refcount corruption. 56bf19c94SChristoph Hellwig# 66bf19c94SChristoph Hellwig# Copyright (C) 2009 Red Hat, Inc. 76bf19c94SChristoph Hellwig# 86bf19c94SChristoph Hellwig# This program is free software; you can redistribute it and/or modify 96bf19c94SChristoph Hellwig# it under the terms of the GNU General Public License as published by 106bf19c94SChristoph Hellwig# the Free Software Foundation; either version 2 of the License, or 116bf19c94SChristoph Hellwig# (at your option) any later version. 126bf19c94SChristoph Hellwig# 136bf19c94SChristoph Hellwig# This program is distributed in the hope that it will be useful, 146bf19c94SChristoph Hellwig# but WITHOUT ANY WARRANTY; without even the implied warranty of 156bf19c94SChristoph Hellwig# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 166bf19c94SChristoph Hellwig# GNU General Public License for more details. 176bf19c94SChristoph Hellwig# 186bf19c94SChristoph Hellwig# You should have received a copy of the GNU General Public License 19e8c212d6SChristoph Hellwig# along with this program. If not, see <http://www.gnu.org/licenses/>. 206bf19c94SChristoph Hellwig# 216bf19c94SChristoph Hellwig 226bf19c94SChristoph Hellwig# creator 236bf19c94SChristoph Hellwigowner=kwolf@redhat.com 246bf19c94SChristoph Hellwig 256bf19c94SChristoph Hellwigseq=`basename $0` 266bf19c94SChristoph Hellwigecho "QA output created by $seq" 276bf19c94SChristoph Hellwig 286bf19c94SChristoph Hellwigstatus=1 # failure is the default! 296bf19c94SChristoph Hellwig 306bf19c94SChristoph Hellwig_cleanup() 316bf19c94SChristoph Hellwig{ 324aa846f2SBharata B Rao _cleanup_test_img 336bf19c94SChristoph Hellwig true 346bf19c94SChristoph Hellwig} 356bf19c94SChristoph Hellwigtrap "_cleanup; exit \$status" 0 1 2 3 15 366bf19c94SChristoph Hellwig 376bf19c94SChristoph Hellwig# get standard environment, filters and checks 386bf19c94SChristoph Hellwig. ./common.rc 396bf19c94SChristoph Hellwig. ./common.filter 406bf19c94SChristoph Hellwig 416bf19c94SChristoph Hellwig# currently only qcow2 allows for consistency checks using qemu-img 426bf19c94SChristoph Hellwig_supported_fmt qcow2 439cdfa1b3SMORITA Kazutaka_supported_proto generic 445262caa7SMax Reitz# refcount_bits must be at least 4 so we can create ten internal snapshots 453be2024aSMax Reitz# (1 bit supports none, 2 bits support two, 4 bits support 14); 463be2024aSMax Reitz# snapshot are generally impossible with external data files 473be2024aSMax Reitz_unsupported_imgopts 'refcount_bits=\(1\|2\)[^0-9]' data_file 486bf19c94SChristoph Hellwig 496bf19c94SChristoph Hellwigecho 506bf19c94SChristoph Hellwigecho "creating image" 516bf19c94SChristoph Hellwig_make_test_img 1M 526bf19c94SChristoph Hellwig 5330edd9faSThomas Huthfor ((i=1;i<=10;i++)); do 546bf19c94SChristoph Hellwig echo "savevm $i" 55fef9c191SJeff Cody $QEMU -nographic -hda "$TEST_IMG" -serial none -monitor stdio >/dev/null 2>&1 <<EOF 566bf19c94SChristoph Hellwigsavevm test-$i 576bf19c94SChristoph Hellwigquit 586bf19c94SChristoph HellwigEOF 596bf19c94SChristoph Hellwigdone 606bf19c94SChristoph Hellwig 616bf19c94SChristoph Hellwigecho 626bf19c94SChristoph Hellwigecho "checking image for errors" 636bf19c94SChristoph Hellwig_check_test_img 646bf19c94SChristoph Hellwig 656bf19c94SChristoph Hellwig# success, all done 666bf19c94SChristoph Hellwigecho "*** done" 676bf19c94SChristoph Hellwigrm -f $seq.full 686bf19c94SChristoph Hellwigstatus=0 69