xref: /qemu/tests/qemu-iotests/068 (revision ab6f2bbb2871db8a7ed2457328e864cdf2e2fc82)
1*ab6f2bbbSMax Reitz#!/bin/bash
2*ab6f2bbbSMax Reitz#
3*ab6f2bbbSMax Reitz# Test case for loading a saved VM state from a qcow2 image
4*ab6f2bbbSMax Reitz#
5*ab6f2bbbSMax Reitz# Copyright (C) 2013 Red Hat, Inc.
6*ab6f2bbbSMax Reitz#
7*ab6f2bbbSMax Reitz# This program is free software; you can redistribute it and/or modify
8*ab6f2bbbSMax Reitz# it under the terms of the GNU General Public License as published by
9*ab6f2bbbSMax Reitz# the Free Software Foundation; either version 2 of the License, or
10*ab6f2bbbSMax Reitz# (at your option) any later version.
11*ab6f2bbbSMax Reitz#
12*ab6f2bbbSMax Reitz# This program is distributed in the hope that it will be useful,
13*ab6f2bbbSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*ab6f2bbbSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*ab6f2bbbSMax Reitz# GNU General Public License for more details.
16*ab6f2bbbSMax Reitz#
17*ab6f2bbbSMax Reitz# You should have received a copy of the GNU General Public License
18*ab6f2bbbSMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*ab6f2bbbSMax Reitz#
20*ab6f2bbbSMax Reitz
21*ab6f2bbbSMax Reitz# creator
22*ab6f2bbbSMax Reitzowner=mreitz@redhat.com
23*ab6f2bbbSMax Reitz
24*ab6f2bbbSMax Reitzseq="$(basename $0)"
25*ab6f2bbbSMax Reitzecho "QA output created by $seq"
26*ab6f2bbbSMax Reitz
27*ab6f2bbbSMax Reitzhere="$PWD"
28*ab6f2bbbSMax Reitztmp=/tmp/$$
29*ab6f2bbbSMax Reitzstatus=1	# failure is the default!
30*ab6f2bbbSMax Reitz
31*ab6f2bbbSMax Reitz_cleanup()
32*ab6f2bbbSMax Reitz{
33*ab6f2bbbSMax Reitz	_cleanup_test_img
34*ab6f2bbbSMax Reitz}
35*ab6f2bbbSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
36*ab6f2bbbSMax Reitz
37*ab6f2bbbSMax Reitz# get standard environment, filters and checks
38*ab6f2bbbSMax Reitz. ./common.rc
39*ab6f2bbbSMax Reitz. ./common.filter
40*ab6f2bbbSMax Reitz
41*ab6f2bbbSMax Reitz# This tests qocw2-specific low-level functionality
42*ab6f2bbbSMax Reitz_supported_fmt qcow2
43*ab6f2bbbSMax Reitz_supported_proto generic
44*ab6f2bbbSMax Reitz_supported_os Linux
45*ab6f2bbbSMax Reitz
46*ab6f2bbbSMax ReitzIMGOPTS="compat=1.1"
47*ab6f2bbbSMax ReitzIMG_SIZE=128K
48*ab6f2bbbSMax Reitz
49*ab6f2bbbSMax Reitzecho
50*ab6f2bbbSMax Reitzecho "=== Saving and reloading a VM state to/from a qcow2 image ==="
51*ab6f2bbbSMax Reitzecho
52*ab6f2bbbSMax Reitz_make_test_img $IMG_SIZE
53*ab6f2bbbSMax Reitz# Give qemu some time to boot before saving the VM state
54*ab6f2bbbSMax Reitzbash -c 'sleep 1; echo -e "savevm 0\nquit"' |\
55*ab6f2bbbSMax Reitz    $QEMU -nographic -monitor stdio -serial none -hda "$TEST_IMG" |\
56*ab6f2bbbSMax Reitz    _filter_qemu
57*ab6f2bbbSMax Reitz# Now try to continue from that VM state (this should just work)
58*ab6f2bbbSMax Reitzecho quit |\
59*ab6f2bbbSMax Reitz    $QEMU -nographic -monitor stdio -serial none -hda "$TEST_IMG" -loadvm 0 |\
60*ab6f2bbbSMax Reitz    _filter_qemu
61*ab6f2bbbSMax Reitz
62*ab6f2bbbSMax Reitz# success, all done
63*ab6f2bbbSMax Reitzecho "*** done"
64*ab6f2bbbSMax Reitzrm -f $seq.full
65*ab6f2bbbSMax Reitzstatus=0
66