Philippe Mathieu-Daudé | 11a82d1 | 2019-03-07 15:58:38 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Vladimir Sementsov-Ogievskiy | 9dd003a | 2021-01-16 16:44:19 +0300 | [diff] [blame] | 2 | # group: rw auto quick |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 3 | # |
Kevin Wolf | 6b7d4c5 | 2014-03-26 13:06:03 +0100 | [diff] [blame] | 4 | # qcow2 internal snapshots/VM state tests |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 5 | # |
| 6 | # Copyright (C) 2011 Red Hat, Inc. |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | # This program is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | # You should have received a copy of the GNU General Public License |
| 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | # |
| 21 | |
| 22 | # creator |
| 23 | owner=kwolf@redhat.com |
| 24 | |
| 25 | seq=`basename $0` |
| 26 | echo "QA output created by $seq" |
| 27 | |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 28 | status=1 # failure is the default! |
| 29 | |
| 30 | _cleanup() |
| 31 | { |
Max Reitz | f91ecbd | 2019-11-07 17:37:01 +0100 | [diff] [blame] | 32 | _rm_test_img "$TEST_IMG.snap" |
Kevin Wolf | c05e466 | 2014-03-26 13:06:05 +0100 | [diff] [blame] | 33 | _cleanup_test_img |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 34 | } |
| 35 | trap "_cleanup; exit \$status" 0 1 2 3 15 |
| 36 | |
| 37 | # get standard environment, filters and checks |
| 38 | . ./common.rc |
| 39 | . ./common.filter |
| 40 | . ./common.pattern |
| 41 | |
Michael Tokarev | 96420a3 | 2023-07-14 14:33:27 +0300 | [diff] [blame] | 42 | # Any format supporting internal snapshots |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 43 | _supported_fmt qcow2 |
| 44 | _supported_proto generic |
Max Reitz | 3be2024 | 2019-11-07 17:37:07 +0100 | [diff] [blame] | 45 | # Internal snapshots are (currently) impossible with refcount_bits=1, |
| 46 | # and generally impossible with external data files |
| 47 | _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 48 | |
Kevin Wolf | c05e466 | 2014-03-26 13:06:05 +0100 | [diff] [blame] | 49 | offset_size=24 |
| 50 | offset_l1_size=36 |
| 51 | |
Kevin Wolf | 6b7d4c5 | 2014-03-26 13:06:03 +0100 | [diff] [blame] | 52 | echo |
| 53 | echo Test loading internal snapshots where the L1 table of the snapshot |
| 54 | echo is smaller than the current L1 table. |
| 55 | echo |
| 56 | |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 57 | CLUSTER_SIZE=65536 |
| 58 | _make_test_img 64M |
Jeff Cody | fef9c19 | 2013-09-25 08:12:22 -0400 | [diff] [blame] | 59 | $QEMU_IMG snapshot -c foo "$TEST_IMG" |
| 60 | $QEMU_IO -c 'write -b 0 4k' "$TEST_IMG" | _filter_qemu_io |
| 61 | $QEMU_IMG snapshot -a foo "$TEST_IMG" |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 62 | _check_test_img |
| 63 | |
| 64 | CLUSTER_SIZE=1024 |
| 65 | _make_test_img 16M |
Jeff Cody | fef9c19 | 2013-09-25 08:12:22 -0400 | [diff] [blame] | 66 | $QEMU_IMG snapshot -c foo "$TEST_IMG" |
| 67 | $QEMU_IO -c 'write -b 0 4M' "$TEST_IMG" | _filter_qemu_io |
| 68 | $QEMU_IMG snapshot -a foo "$TEST_IMG" |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 69 | _check_test_img |
| 70 | |
Kevin Wolf | 6b7d4c5 | 2014-03-26 13:06:03 +0100 | [diff] [blame] | 71 | |
| 72 | echo |
| 73 | echo Try using a huge VM state |
| 74 | echo |
| 75 | |
| 76 | CLUSTER_SIZE=65536 |
| 77 | _make_test_img 64M |
| 78 | { $QEMU_IO -c "write -b -P 0x11 1T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir |
| 79 | { $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir |
| 80 | { $QEMU_IMG snapshot -a foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir |
| 81 | { $QEMU_IO -c "read -b -P 0x11 1T 4k" $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir |
| 82 | _check_test_img |
| 83 | |
| 84 | |
Kevin Wolf | c05e466 | 2014-03-26 13:06:05 +0100 | [diff] [blame] | 85 | echo |
| 86 | echo "qcow2_snapshot_load_tmp() should take the L1 size from the snapshot" |
| 87 | echo |
| 88 | |
| 89 | CLUSTER_SIZE=512 |
| 90 | _make_test_img 64M |
| 91 | { $QEMU_IMG snapshot -c foo $TEST_IMG; } 2>&1 | _filter_qemu_io | _filter_testdir |
| 92 | poke_file "$TEST_IMG" "$offset_size" "\x00\x00\x00\x00\x00\x00\x02\x00" |
| 93 | poke_file "$TEST_IMG" "$offset_l1_size" "\x00\x00\x00\x01" |
Thomas Huth | 46e8d27 | 2018-06-06 14:35:51 +0200 | [diff] [blame] | 94 | { $QEMU_IMG convert -l foo $TEST_IMG $TEST_IMG.snap; } 2>&1 | _filter_qemu_io | _filter_testdir |
Kevin Wolf | c05e466 | 2014-03-26 13:06:05 +0100 | [diff] [blame] | 95 | |
| 96 | |
Kevin Wolf | 8455e4e | 2011-08-05 16:37:25 +0200 | [diff] [blame] | 97 | # success, all done |
| 98 | echo "*** done" |
| 99 | rm -f $seq.full |
| 100 | status=0 |