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