111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2d1fde4adSJeff Cody# 3d1fde4adSJeff Cody# Test for commit of larger active layer 4d1fde4adSJeff Cody# 5d1fde4adSJeff Cody# This tests live snapshots of images on a running QEMU instance, using 6d1fde4adSJeff Cody# QMP commands. Both single disk snapshots, and transactional group 7d1fde4adSJeff Cody# snapshots are performed. 8d1fde4adSJeff Cody# 9d1fde4adSJeff Cody# Copyright (C) 2014 Red Hat, Inc. 10d1fde4adSJeff Cody# 11d1fde4adSJeff Cody# This program is free software; you can redistribute it and/or modify 12d1fde4adSJeff Cody# it under the terms of the GNU General Public License as published by 13d1fde4adSJeff Cody# the Free Software Foundation; either version 2 of the License, or 14d1fde4adSJeff Cody# (at your option) any later version. 15d1fde4adSJeff Cody# 16d1fde4adSJeff Cody# This program is distributed in the hope that it will be useful, 17d1fde4adSJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of 18d1fde4adSJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19d1fde4adSJeff Cody# GNU General Public License for more details. 20d1fde4adSJeff Cody# 21d1fde4adSJeff Cody# You should have received a copy of the GNU General Public License 22d1fde4adSJeff Cody# along with this program. If not, see <http://www.gnu.org/licenses/>. 23d1fde4adSJeff Cody# 24d1fde4adSJeff Cody# creator 25d1fde4adSJeff Codyowner=jcody@redhat.com 26d1fde4adSJeff Cody 27d1fde4adSJeff Codyseq=`basename $0` 28d1fde4adSJeff Codyecho "QA output created by $seq" 29d1fde4adSJeff Cody 30d1fde4adSJeff Codystatus=1 # failure is the default! 31d1fde4adSJeff Cody 32d1fde4adSJeff Cody_cleanup() 33d1fde4adSJeff Cody{ 34d1fde4adSJeff Cody _cleanup_qemu 35f91ecbd7SMax Reitz _rm_test_img "${TEST_IMG}.base" 36f91ecbd7SMax Reitz _rm_test_img "${TEST_IMG}.snp1" 37d1fde4adSJeff Cody _cleanup_test_img 38d1fde4adSJeff Cody} 39d1fde4adSJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15 40d1fde4adSJeff Cody 41d1fde4adSJeff Cody# get standard environment, filters and checks 42d1fde4adSJeff Cody. ./common.rc 43d1fde4adSJeff Cody. ./common.filter 44d1fde4adSJeff Cody. ./common.qemu 45d1fde4adSJeff Cody 46d1fde4adSJeff Cody_supported_fmt qcow2 47d1fde4adSJeff Cody_supported_proto file 48d1fde4adSJeff Cody 49d1fde4adSJeff Codysize_smaller=5M 50d1fde4adSJeff Codysize_larger=100M 51d1fde4adSJeff Cody 5261b42226SFam ZhengTEST_IMG="$TEST_IMG.base" _make_test_img $size_smaller 53d1fde4adSJeff Cody 54*b66ff2c2SEric BlakeTEST_IMG="$TEST_IMG.snp1" _make_test_img -b "$TEST_IMG.base" -F $IMGFMT $size_larger 55d1fde4adSJeff Cody 56*b66ff2c2SEric Blake_make_test_img -b "${TEST_IMG}.snp1" -F $IMGFMT $size_larger 57d1fde4adSJeff Cody 58d1fde4adSJeff Codyecho 59d1fde4adSJeff Codyecho "=== Base image info before commit and resize ===" 60f943078eSFam ZhengTEST_IMG="${TEST_IMG}.base" _img_info | _filter_img_info 61d1fde4adSJeff Cody 62d1fde4adSJeff Codyecho 63d1fde4adSJeff Codyecho === Running QEMU Live Commit Test === 64d1fde4adSJeff Codyecho 65d1fde4adSJeff Cody 66d1fde4adSJeff Codyqemu_comm_method="qmp" 67d1fde4adSJeff Cody_launch_qemu -drive file="${TEST_IMG}",if=virtio,id=test 68d1fde4adSJeff Codyh=$QEMU_HANDLE 69d1fde4adSJeff Cody 70d1fde4adSJeff Cody_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" 71d1fde4adSJeff Cody 72d1fde4adSJeff Cody_send_qemu_cmd $h "{ 'execute': 'block-commit', 73d1fde4adSJeff Cody 'arguments': { 'device': 'test', 741dac83f1SKevin Wolf 'top': '"${TEST_IMG}.snp1"' } }" '"status": "null"' 75d1fde4adSJeff Cody 766ea66b59SFam Zheng_cleanup_qemu 776ea66b59SFam Zheng 78d1fde4adSJeff Codyecho 79d1fde4adSJeff Codyecho "=== Base image info after commit and resize ===" 80f943078eSFam ZhengTEST_IMG="${TEST_IMG}.base" _img_info | _filter_img_info 81d1fde4adSJeff Cody 82d1fde4adSJeff Cody# success, all done 83d1fde4adSJeff Codyecho "*** done" 84d1fde4adSJeff Codyrm -f $seq.full 85d1fde4adSJeff Codystatus=0 86