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