xref: /openbmc/qemu/tests/qemu-iotests/095 (revision 42a5009d)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick
3d1fde4adSJeff Cody#
4d1fde4adSJeff Cody# Test for commit of larger active layer
5d1fde4adSJeff Cody#
6d1fde4adSJeff Cody# This tests live snapshots of images on a running QEMU instance, using
7d1fde4adSJeff Cody# QMP commands.  Both single disk snapshots, and transactional group
8d1fde4adSJeff Cody# snapshots are performed.
9d1fde4adSJeff Cody#
10d1fde4adSJeff Cody# Copyright (C) 2014 Red Hat, Inc.
11d1fde4adSJeff Cody#
12d1fde4adSJeff Cody# This program is free software; you can redistribute it and/or modify
13d1fde4adSJeff Cody# it under the terms of the GNU General Public License as published by
14d1fde4adSJeff Cody# the Free Software Foundation; either version 2 of the License, or
15d1fde4adSJeff Cody# (at your option) any later version.
16d1fde4adSJeff Cody#
17d1fde4adSJeff Cody# This program is distributed in the hope that it will be useful,
18d1fde4adSJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of
19d1fde4adSJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20d1fde4adSJeff Cody# GNU General Public License for more details.
21d1fde4adSJeff Cody#
22d1fde4adSJeff Cody# You should have received a copy of the GNU General Public License
23d1fde4adSJeff Cody# along with this program.  If not, see <http://www.gnu.org/licenses/>.
24d1fde4adSJeff Cody#
25d1fde4adSJeff Cody# creator
26*42a5009dSJohn Snowowner=codyprime@gmail.com
27d1fde4adSJeff Cody
28d1fde4adSJeff Codyseq=`basename $0`
29d1fde4adSJeff Codyecho "QA output created by $seq"
30d1fde4adSJeff Cody
31d1fde4adSJeff Codystatus=1	# failure is the default!
32d1fde4adSJeff Cody
33d1fde4adSJeff Cody_cleanup()
34d1fde4adSJeff Cody{
35d1fde4adSJeff Cody    _cleanup_qemu
36f91ecbd7SMax Reitz    _rm_test_img "${TEST_IMG}.base"
37f91ecbd7SMax Reitz    _rm_test_img "${TEST_IMG}.snp1"
38d1fde4adSJeff Cody    _cleanup_test_img
39d1fde4adSJeff Cody}
40d1fde4adSJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15
41d1fde4adSJeff Cody
42d1fde4adSJeff Cody# get standard environment, filters and checks
43d1fde4adSJeff Cody. ./common.rc
44d1fde4adSJeff Cody. ./common.filter
45d1fde4adSJeff Cody. ./common.qemu
46d1fde4adSJeff Cody
47d1fde4adSJeff Cody_supported_fmt qcow2
4857284d2aSMax Reitz_supported_proto file fuse
49d1fde4adSJeff Cody
50d1fde4adSJeff Codysize_smaller=5M
51d1fde4adSJeff Codysize_larger=100M
52d1fde4adSJeff Cody
5361b42226SFam ZhengTEST_IMG="$TEST_IMG.base" _make_test_img $size_smaller
54d1fde4adSJeff Cody
55b66ff2c2SEric BlakeTEST_IMG="$TEST_IMG.snp1" _make_test_img -b "$TEST_IMG.base" -F $IMGFMT $size_larger
56d1fde4adSJeff Cody
57b66ff2c2SEric Blake_make_test_img -b "${TEST_IMG}.snp1" -F $IMGFMT $size_larger
58d1fde4adSJeff Cody
59d1fde4adSJeff Codyecho
60d1fde4adSJeff Codyecho "=== Base image info before commit and resize ==="
61f943078eSFam ZhengTEST_IMG="${TEST_IMG}.base" _img_info | _filter_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',
751dac83f1SKevin Wolf                                 'top': '"${TEST_IMG}.snp1"' } }" '"status": "null"'
76d1fde4adSJeff Cody
776ea66b59SFam Zheng_cleanup_qemu
786ea66b59SFam Zheng
79d1fde4adSJeff Codyecho
80d1fde4adSJeff Codyecho "=== Base image info after commit and resize ==="
81f943078eSFam ZhengTEST_IMG="${TEST_IMG}.base" _img_info | _filter_img_info
82d1fde4adSJeff Cody
83d1fde4adSJeff Cody# success, all done
84d1fde4adSJeff Codyecho "*** done"
85d1fde4adSJeff Codyrm -f $seq.full
86d1fde4adSJeff Codystatus=0
87