]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/252
build: Remove --enable-gprof
[mirror_qemu.git] / tests / qemu-iotests / 252
CommitLineData
11f6fc50 1#!/usr/bin/env bash
9dd003a9 2# group: rw auto backing quick
11f6fc50
HR
3#
4# Tests for rebasing COW images that require zero cluster support
5#
6# Copyright (C) 2019 Red Hat, Inc.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21
22# creator
42a5009d 23owner=hreitz@redhat.com
11f6fc50
HR
24
25seq=$(basename $0)
26echo "QA output created by $seq"
27
28status=1 # failure is the default!
29
30_cleanup()
31{
32 _cleanup_test_img
f91ecbd7 33 _rm_test_img "$TEST_IMG.base_new"
11f6fc50
HR
34}
35trap "_cleanup; exit \$status" 0 1 2 3 15
36
37# get standard environment, filters and checks
38. ./common.rc
39. ./common.filter
40. ./common.pattern
41
42# Currently only qcow2 and qed support rebasing, and only qcow2 v3 has
43# zero cluster support
44_supported_fmt qcow2
45_unsupported_imgopts 'compat=0.10'
57284d2a 46_supported_proto file fuse
11f6fc50
HR
47_supported_os Linux
48
49CLUSTER_SIZE=65536
50
51echo
52echo "=== Test rebase without input base ==="
53echo
54
55# Cluster allocations to be tested:
56#
57# Backing (new) 11 -- 11 -- 11 --
58# COW image 22 22 11 11 -- --
59#
60# Expected result:
61#
62# COW image 22 22 11 11 00 --
63#
64# (Cluster 2 might be "--" after the rebase, too, but rebase just
65# compares the new backing file to the old one and disregards the
66# overlay. Therefore, it will never discard overlay clusters.)
67
68_make_test_img $((6 * CLUSTER_SIZE))
69TEST_IMG="$TEST_IMG.base_new" _make_test_img $((6 * CLUSTER_SIZE))
70
71echo
72
73$QEMU_IO "$TEST_IMG" \
74 -c "write -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
75 -c "write -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
76 | _filter_qemu_io
77
78$QEMU_IO "$TEST_IMG.base_new" \
79 -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
80 -c "write -P 0x11 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
81 -c "write -P 0x11 $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
82 | _filter_qemu_io
83
84echo
85
86# This should be a no-op
87$QEMU_IMG rebase -b "" "$TEST_IMG"
88
89# Verify the data is correct
90$QEMU_IO "$TEST_IMG" \
91 -c "read -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
92 -c "read -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
93 -c "read -P 0x00 $((4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
94 | _filter_qemu_io
95
96echo
97
98# Verify the allocation status (first four cluster should be allocated
99# in TEST_IMG, clusters 4 and 5 should be unallocated (marked as zero
100# clusters here because there is no backing file))
101$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
102
103echo
104
b66ff2c2 105$QEMU_IMG rebase -b "$TEST_IMG.base_new" -F $IMGFMT "$TEST_IMG"
11f6fc50
HR
106
107# Verify the data is correct
108$QEMU_IO "$TEST_IMG" \
109 -c "read -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
110 -c "read -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
111 -c "read -P 0x00 $((4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
112 | _filter_qemu_io
113
114echo
115
116# Verify the allocation status (first four cluster should be allocated
117# in TEST_IMG, cluster 4 should be zero, and cluster 5 should be
118# unallocated (signified by '"depth": 1'))
119$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
120
121
122# success, all done
123echo "*** done"
124rm -f $seq.full
125status=0