xref: /openbmc/qemu/tests/qemu-iotests/029 (revision f91ecbd74eb75e9d4c7b4016edaf69d070cb3f9b)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
28455e4eeSKevin Wolf#
36b7d4c55SKevin Wolf# qcow2 internal snapshots/VM state tests
48455e4eeSKevin Wolf#
58455e4eeSKevin Wolf# Copyright (C) 2011 Red Hat, Inc.
68455e4eeSKevin Wolf#
78455e4eeSKevin Wolf# This program is free software; you can redistribute it and/or modify
88455e4eeSKevin Wolf# it under the terms of the GNU General Public License as published by
98455e4eeSKevin Wolf# the Free Software Foundation; either version 2 of the License, or
108455e4eeSKevin Wolf# (at your option) any later version.
118455e4eeSKevin Wolf#
128455e4eeSKevin Wolf# This program is distributed in the hope that it will be useful,
138455e4eeSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of
148455e4eeSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
158455e4eeSKevin Wolf# GNU General Public License for more details.
168455e4eeSKevin Wolf#
178455e4eeSKevin Wolf# You should have received a copy of the GNU General Public License
188455e4eeSKevin Wolf# along with this program.  If not, see <http://www.gnu.org/licenses/>.
198455e4eeSKevin Wolf#
208455e4eeSKevin Wolf
218455e4eeSKevin Wolf# creator
228455e4eeSKevin Wolfowner=kwolf@redhat.com
238455e4eeSKevin Wolf
248455e4eeSKevin Wolfseq=`basename $0`
258455e4eeSKevin Wolfecho "QA output created by $seq"
268455e4eeSKevin Wolf
278455e4eeSKevin Wolfstatus=1	# failure is the default!
288455e4eeSKevin Wolf
298455e4eeSKevin Wolf_cleanup()
308455e4eeSKevin Wolf{
31*f91ecbd7SMax Reitz    _rm_test_img "$TEST_IMG.snap"
328455e4eeSKevin Wolf    _cleanup_test_img
338455e4eeSKevin Wolf}
348455e4eeSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
358455e4eeSKevin Wolf
368455e4eeSKevin Wolf# get standard environment, filters and checks
378455e4eeSKevin Wolf. ./common.rc
388455e4eeSKevin Wolf. ./common.filter
398455e4eeSKevin Wolf. ./common.pattern
408455e4eeSKevin Wolf
418455e4eeSKevin Wolf# Any format supporting intenal snapshots
428455e4eeSKevin Wolf_supported_fmt qcow2
438455e4eeSKevin Wolf_supported_proto generic
44a98f49f4SJeff Cody_unsupported_proto vxhs
455262caa7SMax Reitz# Internal snapshots are (currently) impossible with refcount_bits=1
465262caa7SMax Reitz_unsupported_imgopts 'refcount_bits=1[^0-9]'
478455e4eeSKevin Wolf
48c05e4667SKevin Wolfoffset_size=24
49c05e4667SKevin Wolfoffset_l1_size=36
50c05e4667SKevin Wolf
516b7d4c55SKevin Wolfecho
526b7d4c55SKevin Wolfecho Test loading internal snapshots where the L1 table of the snapshot
536b7d4c55SKevin Wolfecho is smaller than the current L1 table.
546b7d4c55SKevin Wolfecho
556b7d4c55SKevin Wolf
568455e4eeSKevin WolfCLUSTER_SIZE=65536
578455e4eeSKevin Wolf_make_test_img 64M
58fef9c191SJeff Cody$QEMU_IMG snapshot -c foo "$TEST_IMG"
59fef9c191SJeff Cody$QEMU_IO -c 'write -b 0 4k' "$TEST_IMG" | _filter_qemu_io
60fef9c191SJeff Cody$QEMU_IMG snapshot -a foo "$TEST_IMG"
618455e4eeSKevin Wolf_check_test_img
628455e4eeSKevin Wolf
638455e4eeSKevin WolfCLUSTER_SIZE=1024
648455e4eeSKevin Wolf_make_test_img 16M
65fef9c191SJeff Cody$QEMU_IMG snapshot -c foo "$TEST_IMG"
66fef9c191SJeff Cody$QEMU_IO -c 'write -b 0 4M' "$TEST_IMG" | _filter_qemu_io
67fef9c191SJeff Cody$QEMU_IMG snapshot -a foo "$TEST_IMG"
688455e4eeSKevin Wolf_check_test_img
698455e4eeSKevin Wolf
706b7d4c55SKevin Wolf
716b7d4c55SKevin Wolfecho
726b7d4c55SKevin Wolfecho Try using a huge VM state
736b7d4c55SKevin Wolfecho
746b7d4c55SKevin Wolf
756b7d4c55SKevin WolfCLUSTER_SIZE=65536
766b7d4c55SKevin Wolf_make_test_img 64M
776b7d4c55SKevin Wolf{ $QEMU_IO -c "write -b -P 0x11 1T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
786b7d4c55SKevin Wolf{ $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
796b7d4c55SKevin Wolf{ $QEMU_IMG snapshot -a foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
806b7d4c55SKevin Wolf{ $QEMU_IO -c "read -b -P 0x11 1T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
816b7d4c55SKevin Wolf_check_test_img
826b7d4c55SKevin Wolf
836b7d4c55SKevin Wolf
84c05e4667SKevin Wolfecho
85c05e4667SKevin Wolfecho "qcow2_snapshot_load_tmp() should take the L1 size from the snapshot"
86c05e4667SKevin Wolfecho
87c05e4667SKevin Wolf
88c05e4667SKevin WolfCLUSTER_SIZE=512
89c05e4667SKevin Wolf_make_test_img 64M
90c05e4667SKevin Wolf{ $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
91c05e4667SKevin Wolfpoke_file "$TEST_IMG" "$offset_size" "\x00\x00\x00\x00\x00\x00\x02\x00"
92c05e4667SKevin Wolfpoke_file "$TEST_IMG" "$offset_l1_size" "\x00\x00\x00\x01"
9346e8d272SThomas Huth{ $QEMU_IMG convert -l foo $TEST_IMG $TEST_IMG.snap; } 2>&1 | _filter_qemu_io | _filter_testdir
94c05e4667SKevin Wolf
95c05e4667SKevin Wolf
968455e4eeSKevin Wolf# success, all done
978455e4eeSKevin Wolfecho "*** done"
988455e4eeSKevin Wolfrm -f $seq.full
998455e4eeSKevin Wolfstatus=0
100