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