qtest/ahci: rename 'Command' to 'CommandHeader'
[qemu/ar7.git] / tests / qemu-iotests / 029
blobfa46ace67b4a358a19709ea0eb9cd66ce0301d67
1 #!/bin/bash
3 # qcow2 internal snapshots/VM state tests
5 # Copyright (C) 2011 Red Hat, Inc.
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.
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.
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/>.
21 # creator
22 owner=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 here=`pwd`
28 tmp=/tmp/$$
29 status=1 # failure is the default!
31 _cleanup()
33 rm -f $TEST_IMG.snap
34 _cleanup_test_img
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
41 . ./common.pattern
43 # Any format supporting intenal snapshots
44 _supported_fmt qcow2
45 _supported_proto generic
46 _supported_os Linux
48 offset_size=24
49 offset_l1_size=36
51 echo
52 echo Test loading internal snapshots where the L1 table of the snapshot
53 echo is smaller than the current L1 table.
54 echo
56 CLUSTER_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
63 CLUSTER_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
71 echo
72 echo Try using a huge VM state
73 echo
75 CLUSTER_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
84 echo
85 echo "qcow2_snapshot_load_tmp() should take the L1 size from the snapshot"
86 echo
88 CLUSTER_SIZE=512
89 _make_test_img 64M
90 { $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
91 poke_file "$TEST_IMG" "$offset_size" "\x00\x00\x00\x00\x00\x00\x02\x00"
92 poke_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
96 # success, all done
97 echo "*** done"
98 rm -f $seq.full
99 status=0