xref: /qemu/tests/qemu-iotests/095 (revision bfa3ab61)
1#!/bin/bash
2#
3# Test for commit of larger active layer
4#
5# This tests live snapshots of images on a running QEMU instance, using
6# QMP commands.  Both single disk snapshots, and transactional group
7# snapshots are performed.
8#
9# Copyright (C) 2014 Red Hat, Inc.
10#
11# This program is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program.  If not, see <http://www.gnu.org/licenses/>.
23#
24# creator
25owner=jcody@redhat.com
26
27seq=`basename $0`
28echo "QA output created by $seq"
29
30here=`pwd`
31status=1	# failure is the default!
32
33_cleanup()
34{
35    _cleanup_qemu
36    rm  -f "${TEST_IMG}.base" "${TEST_IMG}.snp1"
37	_cleanup_test_img
38}
39trap "_cleanup; exit \$status" 0 1 2 3 15
40
41# get standard environment, filters and checks
42. ./common.rc
43. ./common.filter
44. ./common.qemu
45
46_supported_fmt qcow2
47_supported_proto file
48_supported_os Linux
49
50size_smaller=5M
51size_larger=100M
52
53_make_test_img $size_smaller
54mv "${TEST_IMG}" "${TEST_IMG}.base"
55
56_make_test_img -b "${TEST_IMG}.base" $size_larger
57mv "${TEST_IMG}" "${TEST_IMG}.snp1"
58
59_make_test_img -b "${TEST_IMG}.snp1" $size_larger
60
61echo
62echo "=== Base image info before commit and resize ==="
63TEST_IMG="${TEST_IMG}.base" _img_info
64
65echo
66echo === Running QEMU Live Commit Test ===
67echo
68
69qemu_comm_method="qmp"
70_launch_qemu -drive file="${TEST_IMG}",if=virtio,id=test
71h=$QEMU_HANDLE
72
73_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return"
74
75_send_qemu_cmd $h "{ 'execute': 'block-commit',
76                                 'arguments': { 'device': 'test',
77                                 'top': '"${TEST_IMG}.snp1"' } }" "BLOCK_JOB_COMPLETED"
78
79echo
80echo "=== Base image info after commit and resize ==="
81TEST_IMG="${TEST_IMG}.base" _img_info
82
83# success, all done
84echo "*** done"
85rm -f $seq.full
86status=0
87