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