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