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