18455e4eeSKevin Wolf#!/bin/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 Wolfhere=`pwd` 288455e4eeSKevin Wolftmp=/tmp/$$ 298455e4eeSKevin Wolfstatus=1 # failure is the default! 308455e4eeSKevin Wolf 318455e4eeSKevin Wolf_cleanup() 328455e4eeSKevin Wolf{ 33*c05e4667SKevin Wolf rm -f $TEST_IMG.snap 348455e4eeSKevin Wolf _cleanup_test_img 358455e4eeSKevin Wolf} 368455e4eeSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 378455e4eeSKevin Wolf 388455e4eeSKevin Wolf# get standard environment, filters and checks 398455e4eeSKevin Wolf. ./common.rc 408455e4eeSKevin Wolf. ./common.filter 418455e4eeSKevin Wolf. ./common.pattern 428455e4eeSKevin Wolf 438455e4eeSKevin Wolf# Any format supporting intenal snapshots 448455e4eeSKevin Wolf_supported_fmt qcow2 458455e4eeSKevin Wolf_supported_proto generic 468455e4eeSKevin Wolf_supported_os Linux 478455e4eeSKevin Wolf 48*c05e4667SKevin Wolfoffset_size=24 49*c05e4667SKevin Wolfoffset_l1_size=36 50*c05e4667SKevin 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 84*c05e4667SKevin Wolfecho 85*c05e4667SKevin Wolfecho "qcow2_snapshot_load_tmp() should take the L1 size from the snapshot" 86*c05e4667SKevin Wolfecho 87*c05e4667SKevin Wolf 88*c05e4667SKevin WolfCLUSTER_SIZE=512 89*c05e4667SKevin Wolf_make_test_img 64M 90*c05e4667SKevin Wolf{ $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir 91*c05e4667SKevin Wolfpoke_file "$TEST_IMG" "$offset_size" "\x00\x00\x00\x00\x00\x00\x02\x00" 92*c05e4667SKevin Wolfpoke_file "$TEST_IMG" "$offset_l1_size" "\x00\x00\x00\x01" 93*c05e4667SKevin Wolf{ $QEMU_IMG convert -s foo $TEST_IMG $TEST_IMG.snap; } 2>&1 | _filter_qemu_io | _filter_testdir 94*c05e4667SKevin Wolf 95*c05e4667SKevin Wolf 968455e4eeSKevin Wolf# success, all done 978455e4eeSKevin Wolfecho "*** done" 988455e4eeSKevin Wolfrm -f $seq.full 998455e4eeSKevin Wolfstatus=0 100