xref: /openbmc/qemu/tests/qemu-iotests/029 (revision a719a27c)
1#!/bin/bash
2#
3# qcow2 internal snapshots/VM state tests
4#
5# Copyright (C) 2011 Red Hat, Inc.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19#
20
21# creator
22owner=kwolf@redhat.com
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
27here=`pwd`
28tmp=/tmp/$$
29status=1	# failure is the default!
30
31_cleanup()
32{
33    rm -f $TEST_IMG.snap
34    _cleanup_test_img
35}
36trap "_cleanup; exit \$status" 0 1 2 3 15
37
38# get standard environment, filters and checks
39. ./common.rc
40. ./common.filter
41. ./common.pattern
42
43# Any format supporting intenal snapshots
44_supported_fmt qcow2
45_supported_proto generic
46_supported_os Linux
47
48offset_size=24
49offset_l1_size=36
50
51echo
52echo Test loading internal snapshots where the L1 table of the snapshot
53echo is smaller than the current L1 table.
54echo
55
56CLUSTER_SIZE=65536
57_make_test_img 64M
58$QEMU_IMG snapshot -c foo "$TEST_IMG"
59$QEMU_IO -c 'write -b 0 4k' "$TEST_IMG" | _filter_qemu_io
60$QEMU_IMG snapshot -a foo "$TEST_IMG"
61_check_test_img
62
63CLUSTER_SIZE=1024
64_make_test_img 16M
65$QEMU_IMG snapshot -c foo "$TEST_IMG"
66$QEMU_IO -c 'write -b 0 4M' "$TEST_IMG" | _filter_qemu_io
67$QEMU_IMG snapshot -a foo "$TEST_IMG"
68_check_test_img
69
70
71echo
72echo Try using a huge VM state
73echo
74
75CLUSTER_SIZE=65536
76_make_test_img 64M
77{ $QEMU_IO -c "write -b -P 0x11 1T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
78{ $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
79{ $QEMU_IMG snapshot -a foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
80{ $QEMU_IO -c "read -b -P 0x11 1T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
81_check_test_img
82
83
84echo
85echo "qcow2_snapshot_load_tmp() should take the L1 size from the snapshot"
86echo
87
88CLUSTER_SIZE=512
89_make_test_img 64M
90{ $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
91poke_file "$TEST_IMG" "$offset_size" "\x00\x00\x00\x00\x00\x00\x02\x00"
92poke_file "$TEST_IMG" "$offset_l1_size" "\x00\x00\x00\x01"
93{ $QEMU_IMG convert -s foo $TEST_IMG $TEST_IMG.snap; } 2>&1 | _filter_qemu_io | _filter_testdir
94
95
96# success, all done
97echo "*** done"
98rm -f $seq.full
99status=0
100