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