xref: /openbmc/qemu/tests/qemu-iotests/062 (revision b043b07c)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
2449df706SMax Reitz#
3449df706SMax Reitz# Test case for snapshotting images with unallocated zero clusters in
4449df706SMax Reitz# qcow2
5449df706SMax Reitz#
6449df706SMax Reitz# Copyright (C) 2013 Red Hat, Inc.
7449df706SMax Reitz#
8449df706SMax Reitz# This program is free software; you can redistribute it and/or modify
9449df706SMax Reitz# it under the terms of the GNU General Public License as published by
10449df706SMax Reitz# the Free Software Foundation; either version 2 of the License, or
11449df706SMax Reitz# (at your option) any later version.
12449df706SMax Reitz#
13449df706SMax Reitz# This program is distributed in the hope that it will be useful,
14449df706SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
15449df706SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16449df706SMax Reitz# GNU General Public License for more details.
17449df706SMax Reitz#
18449df706SMax Reitz# You should have received a copy of the GNU General Public License
19449df706SMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20449df706SMax Reitz#
21449df706SMax Reitz
22449df706SMax Reitz# creator
23449df706SMax Reitzowner=mreitz@redhat.com
24449df706SMax Reitz
25449df706SMax Reitzseq=`basename $0`
26449df706SMax Reitzecho "QA output created by $seq"
27449df706SMax Reitz
28449df706SMax Reitzstatus=1	# failure is the default!
29449df706SMax Reitz
30449df706SMax Reitz_cleanup()
31449df706SMax Reitz{
32449df706SMax Reitz	_cleanup_test_img
33449df706SMax Reitz}
34449df706SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
35449df706SMax Reitz
36449df706SMax Reitz# get standard environment, filters and checks
37449df706SMax Reitz. ./common.rc
38449df706SMax Reitz. ./common.filter
39449df706SMax Reitz
40e696f335SMax Reitz# This tests qcow2-specific low-level functionality
41449df706SMax Reitz_supported_fmt qcow2
42449df706SMax Reitz_supported_proto generic
43*b043b07cSMax Reitz# We need zero clusters and snapshots
44*b043b07cSMax Reitz_unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]'
45449df706SMax Reitz
46449df706SMax ReitzIMG_SIZE=64M
47449df706SMax Reitz
48449df706SMax Reitzecho
49449df706SMax Reitzecho "=== Testing snapshotting an image with zero clusters ==="
50449df706SMax Reitzecho
51449df706SMax Reitz_make_test_img $IMG_SIZE
52449df706SMax Reitz# Write some zero clusters
53449df706SMax Reitz$QEMU_IO -c "write -z 0 256k" "$TEST_IMG" | _filter_qemu_io
54449df706SMax Reitz# Create a snapshot
55449df706SMax Reitz$QEMU_IMG snapshot -c foo "$TEST_IMG"
56449df706SMax Reitz# Check the image (there shouldn't be any errors or leaks)
57449df706SMax Reitz_check_test_img
58449df706SMax Reitz
59449df706SMax Reitz# success, all done
60449df706SMax Reitzecho "*** done"
61449df706SMax Reitzrm -f $seq.full
62449df706SMax Reitzstatus=0
63