xref: /qemu/tests/qemu-iotests/286 (revision dff8d44c96f128480430b0c59ed8760917dbd427)
1*dff8d44cSMax Reitz#!/usr/bin/env bash
2*dff8d44cSMax Reitz#
3*dff8d44cSMax Reitz# Test qemu-img snapshot -l
4*dff8d44cSMax Reitz#
5*dff8d44cSMax Reitz# Copyright (C) 2019 Red Hat, Inc.
6*dff8d44cSMax Reitz#
7*dff8d44cSMax Reitz# This program is free software; you can redistribute it and/or modify
8*dff8d44cSMax Reitz# it under the terms of the GNU General Public License as published by
9*dff8d44cSMax Reitz# the Free Software Foundation; either version 2 of the License, or
10*dff8d44cSMax Reitz# (at your option) any later version.
11*dff8d44cSMax Reitz#
12*dff8d44cSMax Reitz# This program is distributed in the hope that it will be useful,
13*dff8d44cSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*dff8d44cSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*dff8d44cSMax Reitz# GNU General Public License for more details.
16*dff8d44cSMax Reitz#
17*dff8d44cSMax Reitz# You should have received a copy of the GNU General Public License
18*dff8d44cSMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*dff8d44cSMax Reitz#
20*dff8d44cSMax Reitz
21*dff8d44cSMax Reitzseq=$(basename "$0")
22*dff8d44cSMax Reitzecho "QA output created by $seq"
23*dff8d44cSMax Reitz
24*dff8d44cSMax Reitzstatus=1	# failure is the default!
25*dff8d44cSMax Reitz
26*dff8d44cSMax Reitz_cleanup()
27*dff8d44cSMax Reitz{
28*dff8d44cSMax Reitz    _cleanup_test_img
29*dff8d44cSMax Reitz}
30*dff8d44cSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
31*dff8d44cSMax Reitz
32*dff8d44cSMax Reitz# get standard environment, filters and checks
33*dff8d44cSMax Reitz. ./common.rc
34*dff8d44cSMax Reitz. ./common.filter
35*dff8d44cSMax Reitz. ./common.qemu
36*dff8d44cSMax Reitz
37*dff8d44cSMax Reitz_supported_fmt qcow2
38*dff8d44cSMax Reitz_supported_proto file
39*dff8d44cSMax Reitz# Internal snapshots are (currently) impossible with refcount_bits=1,
40*dff8d44cSMax Reitz# and generally impossible with external data files
41*dff8d44cSMax Reitz_unsupported_imgopts 'refcount_bits=1[^0-9]' data_file
42*dff8d44cSMax Reitz
43*dff8d44cSMax Reitz_make_test_img 64M
44*dff8d44cSMax Reitz
45*dff8d44cSMax Reitz# Should be so long as to take up the whole field width
46*dff8d44cSMax Reitzsn_name=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
47*dff8d44cSMax Reitz
48*dff8d44cSMax Reitz# More memory will give us a larger VM state, i.e. one above 1 MB.
49*dff8d44cSMax Reitz# This way, we get a number with a decimal point.
50*dff8d44cSMax Reitzqemu_comm_method=monitor _launch_qemu -m 512 "$TEST_IMG"
51*dff8d44cSMax Reitz
52*dff8d44cSMax Reitz_send_qemu_cmd $QEMU_HANDLE "savevm $sn_name" '(qemu)'
53*dff8d44cSMax Reitz_send_qemu_cmd $QEMU_HANDLE 'quit' '(qemu)'
54*dff8d44cSMax Reitzwait=yes _cleanup_qemu
55*dff8d44cSMax Reitz
56*dff8d44cSMax Reitz# Check that all fields are separated by spaces.
57*dff8d44cSMax Reitz# We first collapse all space sequences into one space each;
58*dff8d44cSMax Reitz# then we turn every space-separated field into a '.';
59*dff8d44cSMax Reitz# and finally, we name the '.'s so the output is not just a confusing
60*dff8d44cSMax Reitz# sequence of dots.
61*dff8d44cSMax Reitz
62*dff8d44cSMax Reitzecho 'Output structure:'
63*dff8d44cSMax Reitz$QEMU_IMG snapshot -l "$TEST_IMG" | tail -n 1 | tr -s ' ' \
64*dff8d44cSMax Reitz    | sed -e 's/\S\+/./g' \
65*dff8d44cSMax Reitz    | sed -e 's/\./(snapshot ID)/' \
66*dff8d44cSMax Reitz          -e 's/\./(snapshot name)/' \
67*dff8d44cSMax Reitz          -e 's/\./(VM state size value)/' \
68*dff8d44cSMax Reitz          -e 's/\./(VM state size unit)/' \
69*dff8d44cSMax Reitz          -e 's/\./(snapshot date)/' \
70*dff8d44cSMax Reitz          -e 's/\./(snapshot time)/' \
71*dff8d44cSMax Reitz          -e 's/\./(VM clock)/'
72*dff8d44cSMax Reitz
73*dff8d44cSMax Reitz# success, all done
74*dff8d44cSMax Reitzecho "*** done"
75*dff8d44cSMax Reitzrm -f $seq.full
76*dff8d44cSMax Reitzstatus=0
77