xref: /openbmc/qemu/tests/qemu-iotests/095 (revision 61b42226)
1d1fde4adSJeff Cody#!/bin/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 Codyhere=`pwd`
31d1fde4adSJeff Codystatus=1	# failure is the default!
32d1fde4adSJeff Cody
33d1fde4adSJeff Cody_cleanup()
34d1fde4adSJeff Cody{
35d1fde4adSJeff Cody    _cleanup_qemu
36d1fde4adSJeff Cody    rm  -f "${TEST_IMG}.base" "${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_supported_os Linux
49d1fde4adSJeff Cody
50d1fde4adSJeff Codysize_smaller=5M
51d1fde4adSJeff Codysize_larger=100M
52d1fde4adSJeff Cody
53*61b42226SFam ZhengTEST_IMG="$TEST_IMG.base" _make_test_img $size_smaller
54d1fde4adSJeff Cody
55*61b42226SFam ZhengTEST_IMG="$TEST_IMG.snp1" _make_test_img -b "$TEST_IMG.base" $size_larger
56d1fde4adSJeff Cody
57d1fde4adSJeff Cody_make_test_img -b "${TEST_IMG}.snp1" $size_larger
58d1fde4adSJeff Cody
59d1fde4adSJeff Codyecho
60d1fde4adSJeff Codyecho "=== Base image info before commit and resize ==="
611b53eab2SMax ReitzTEST_IMG="${TEST_IMG}.base" _img_info
62d1fde4adSJeff Cody
63d1fde4adSJeff Codyecho
64d1fde4adSJeff Codyecho === Running QEMU Live Commit Test ===
65d1fde4adSJeff Codyecho
66d1fde4adSJeff Cody
67d1fde4adSJeff Codyqemu_comm_method="qmp"
68d1fde4adSJeff Cody_launch_qemu -drive file="${TEST_IMG}",if=virtio,id=test
69d1fde4adSJeff Codyh=$QEMU_HANDLE
70d1fde4adSJeff Cody
71d1fde4adSJeff Cody_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return"
72d1fde4adSJeff Cody
73d1fde4adSJeff Cody_send_qemu_cmd $h "{ 'execute': 'block-commit',
74d1fde4adSJeff Cody                                 'arguments': { 'device': 'test',
75d1fde4adSJeff Cody                                 'top': '"${TEST_IMG}.snp1"' } }" "BLOCK_JOB_COMPLETED"
76d1fde4adSJeff Cody
77d1fde4adSJeff Codyecho
78d1fde4adSJeff Codyecho "=== Base image info after commit and resize ==="
791b53eab2SMax ReitzTEST_IMG="${TEST_IMG}.base" _img_info
80d1fde4adSJeff Cody
81d1fde4adSJeff Cody# success, all done
82d1fde4adSJeff Codyecho "*** done"
83d1fde4adSJeff Codyrm -f $seq.full
84d1fde4adSJeff Codystatus=0
85