xref: /openbmc/qemu/tests/qemu-iotests/029 (revision 6b7d4c55586a849aa8313282d79432917eade3bf)
18455e4eeSKevin Wolf#!/bin/bash
28455e4eeSKevin Wolf#
3*6b7d4c55SKevin 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 Wolfhere=`pwd`
288455e4eeSKevin Wolftmp=/tmp/$$
298455e4eeSKevin Wolfstatus=1	# failure is the default!
308455e4eeSKevin Wolf
318455e4eeSKevin Wolf_cleanup()
328455e4eeSKevin Wolf{
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
428455e4eeSKevin Wolf# Any format supporting intenal snapshots
438455e4eeSKevin Wolf_supported_fmt qcow2
448455e4eeSKevin Wolf_supported_proto generic
458455e4eeSKevin Wolf_supported_os Linux
468455e4eeSKevin Wolf
47*6b7d4c55SKevin Wolfecho
48*6b7d4c55SKevin Wolfecho Test loading internal snapshots where the L1 table of the snapshot
49*6b7d4c55SKevin Wolfecho is smaller than the current L1 table.
50*6b7d4c55SKevin Wolfecho
51*6b7d4c55SKevin Wolf
528455e4eeSKevin WolfCLUSTER_SIZE=65536
538455e4eeSKevin Wolf_make_test_img 64M
54fef9c191SJeff Cody$QEMU_IMG snapshot -c foo "$TEST_IMG"
55fef9c191SJeff Cody$QEMU_IO -c 'write -b 0 4k' "$TEST_IMG" | _filter_qemu_io
56fef9c191SJeff Cody$QEMU_IMG snapshot -a foo "$TEST_IMG"
578455e4eeSKevin Wolf_check_test_img
588455e4eeSKevin Wolf
598455e4eeSKevin WolfCLUSTER_SIZE=1024
608455e4eeSKevin Wolf_make_test_img 16M
61fef9c191SJeff Cody$QEMU_IMG snapshot -c foo "$TEST_IMG"
62fef9c191SJeff Cody$QEMU_IO -c 'write -b 0 4M' "$TEST_IMG" | _filter_qemu_io
63fef9c191SJeff Cody$QEMU_IMG snapshot -a foo "$TEST_IMG"
648455e4eeSKevin Wolf_check_test_img
658455e4eeSKevin Wolf
66*6b7d4c55SKevin Wolf
67*6b7d4c55SKevin Wolfecho
68*6b7d4c55SKevin Wolfecho Try using a huge VM state
69*6b7d4c55SKevin Wolfecho
70*6b7d4c55SKevin Wolf
71*6b7d4c55SKevin WolfCLUSTER_SIZE=65536
72*6b7d4c55SKevin Wolf_make_test_img 64M
73*6b7d4c55SKevin Wolf{ $QEMU_IO -c "write -b -P 0x11 1T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
74*6b7d4c55SKevin Wolf{ $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
75*6b7d4c55SKevin Wolf{ $QEMU_IMG snapshot -a foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
76*6b7d4c55SKevin Wolf{ $QEMU_IO -c "read -b -P 0x11 1T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir
77*6b7d4c55SKevin Wolf_check_test_img
78*6b7d4c55SKevin Wolf
79*6b7d4c55SKevin Wolf
808455e4eeSKevin Wolf# success, all done
818455e4eeSKevin Wolfecho "*** done"
828455e4eeSKevin Wolfrm -f $seq.full
838455e4eeSKevin Wolfstatus=0
84