xref: /openbmc/qemu/tests/qemu-iotests/050 (revision ae7e0bf4)
1acbf30ecSPaolo Bonzini#!/bin/bash
2acbf30ecSPaolo Bonzini#
3acbf30ecSPaolo Bonzini# Test qemu-img rebase with zero clusters
4acbf30ecSPaolo Bonzini#
5acbf30ecSPaolo Bonzini# Copyright (C) 2013 Red Hat, Inc.
6acbf30ecSPaolo Bonzini#
7acbf30ecSPaolo Bonzini# This program is free software; you can redistribute it and/or modify
8acbf30ecSPaolo Bonzini# it under the terms of the GNU General Public License as published by
9acbf30ecSPaolo Bonzini# the Free Software Foundation; either version 2 of the License, or
10acbf30ecSPaolo Bonzini# (at your option) any later version.
11acbf30ecSPaolo Bonzini#
12acbf30ecSPaolo Bonzini# This program is distributed in the hope that it will be useful,
13acbf30ecSPaolo Bonzini# but WITHOUT ANY WARRANTY; without even the implied warranty of
14acbf30ecSPaolo Bonzini# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15acbf30ecSPaolo Bonzini# GNU General Public License for more details.
16acbf30ecSPaolo Bonzini#
17acbf30ecSPaolo Bonzini# You should have received a copy of the GNU General Public License
18acbf30ecSPaolo Bonzini# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19acbf30ecSPaolo Bonzini#
20acbf30ecSPaolo Bonzini
21acbf30ecSPaolo Bonzini# creator
22acbf30ecSPaolo Bonziniowner=pbonzini@redhat.com
23acbf30ecSPaolo Bonzini
24acbf30ecSPaolo Bonziniseq=`basename $0`
25acbf30ecSPaolo Bonziniecho "QA output created by $seq"
26acbf30ecSPaolo Bonzini
27acbf30ecSPaolo Bonzinihere=`pwd`
28acbf30ecSPaolo Bonzinitmp=/tmp/$$
29acbf30ecSPaolo Bonzinistatus=1	# failure is the default!
30acbf30ecSPaolo Bonzini
31acbf30ecSPaolo Bonzini_cleanup()
32acbf30ecSPaolo Bonzini{
33acbf30ecSPaolo Bonzini    _cleanup_test_img
34fef9c191SJeff Cody    rm -f "$TEST_IMG.old"
35fef9c191SJeff Cody    rm -f "$TEST_IMG.new"
36acbf30ecSPaolo Bonzini}
37acbf30ecSPaolo Bonzinitrap "_cleanup; exit \$status" 0 1 2 3 15
38acbf30ecSPaolo Bonzini
39acbf30ecSPaolo Bonzini# get standard environment, filters and checks
40acbf30ecSPaolo Bonzini. ./common.rc
41acbf30ecSPaolo Bonzini. ./common.filter
42acbf30ecSPaolo Bonzini
43acbf30ecSPaolo Bonzini_supported_fmt qcow2 qed
44acbf30ecSPaolo Bonzini_supported_proto file
45acbf30ecSPaolo Bonzini_supported_os Linux
46acbf30ecSPaolo Bonzini
47acbf30ecSPaolo Bonziniif test "$IMGFMT" = qcow2 && test $IMGOPTS = ""; then
48acbf30ecSPaolo Bonzini  IMGOPTS=compat=1.1
49acbf30ecSPaolo Bonzinifi
50acbf30ecSPaolo Bonzini
51acbf30ecSPaolo Bonziniecho
52acbf30ecSPaolo Bonziniecho "== Creating images =="
53acbf30ecSPaolo Bonzini
54*ae7e0bf4SFam ZhengTEST_IMG_SAVE="$TEST_IMG"
55*ae7e0bf4SFam ZhengTEST_IMG="$TEST_IMG.old"
56*ae7e0bf4SFam Zheng
57acbf30ecSPaolo Bonzinisize=10M
58acbf30ecSPaolo Bonzini_make_test_img $size
59fef9c191SJeff Cody$QEMU_IO -c "write -P 0x40 0 1048576" "$TEST_IMG" | _filter_qemu_io
60*ae7e0bf4SFam Zheng
61*ae7e0bf4SFam ZhengTEST_IMG="$TEST_IMG_SAVE.new"
62acbf30ecSPaolo Bonzini
63acbf30ecSPaolo Bonzini_make_test_img $size
64fef9c191SJeff Cody$QEMU_IO -c "write -P 0x5a 0 1048576" "$TEST_IMG" | _filter_qemu_io
65*ae7e0bf4SFam Zheng
66*ae7e0bf4SFam ZhengTEST_IMG="$TEST_IMG_SAVE"
67acbf30ecSPaolo Bonzini
68fef9c191SJeff Cody_make_test_img -b "$TEST_IMG.old" $size
69fef9c191SJeff Cody$QEMU_IO -c "write -z 0 1048576" "$TEST_IMG" | _filter_qemu_io
70acbf30ecSPaolo Bonzini
71acbf30ecSPaolo Bonziniecho
72acbf30ecSPaolo Bonziniecho "== Rebasing the image =="
73acbf30ecSPaolo Bonzini
74fef9c191SJeff Cody$QEMU_IMG rebase -b "$TEST_IMG.new" "$TEST_IMG"
75fef9c191SJeff Cody$QEMU_IO -c "read -P 0x00 0 1048576" "$TEST_IMG" | _filter_qemu_io
76acbf30ecSPaolo Bonzini
77acbf30ecSPaolo Bonzini# success, all done
78acbf30ecSPaolo Bonziniecho "*** done"
79acbf30ecSPaolo Bonzinirm -f $seq.full
80acbf30ecSPaolo Bonzinistatus=0
81