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