xref: /openbmc/qemu/tests/qemu-iotests/144 (revision 4921d0a7)
1#!/usr/bin/env bash
2# group: rw quick
3# Check live snapshot, followed by active commit, and another snapshot.
4#
5# This test is to catch the error case of BZ #1300209:
6# https://bugzilla.redhat.com/show_bug.cgi?id=1300209
7#
8# Copyright (C) 2016 Red Hat, Inc.
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22#
23
24# creator
25owner=codyprime@gmail.com
26
27seq=`basename $0`
28echo "QA output created by $seq"
29
30status=1	# failure is the default!
31
32TMP_SNAP1=${TEST_DIR}/tmp.qcow2
33TMP_SNAP2=${TEST_DIR}/tmp2.qcow2
34
35_cleanup()
36{
37    _cleanup_qemu
38    for img in "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"; do
39        _rm_test_img "$img"
40    done
41}
42
43trap "_cleanup; exit \$status" 0 1 2 3 15
44
45# get standard environment, filters and checks
46. ./common.rc
47. ./common.filter
48. ./common.qemu
49
50_supported_fmt qcow2
51_supported_proto file
52
53size=512M
54
55_make_test_img $size
56
57echo
58echo === Launching QEMU ===
59echo
60
61qemu_comm_method="qmp"
62_launch_qemu -drive file="${TEST_IMG}",if=virtio
63h=$QEMU_HANDLE
64
65
66echo
67echo === Performing Live Snapshot 1 ===
68echo
69
70_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return"
71
72
73# First live snapshot, new overlay as active layer
74_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync',
75                                'arguments': {
76                                             'device': 'virtio0',
77                                             'snapshot-file':'${TMP_SNAP1}',
78                                             'format': 'qcow2'
79                                             }
80                    }" "return"
81
82echo
83echo === Performing block-commit on active layer ===
84echo
85
86capture_events="BLOCK_JOB_READY JOB_STATUS_CHANGE"
87
88# Block commit on active layer, push the new overlay into base
89_send_qemu_cmd $h "{ 'execute': 'block-commit',
90                                'arguments': {
91                                                 'device': 'virtio0'
92                                              }
93                    }" "return"
94
95_wait_event $h "JOB_STATUS_CHANGE"
96_wait_event $h "JOB_STATUS_CHANGE"
97_wait_event $h "JOB_STATUS_CHANGE"
98
99_wait_event $h "BLOCK_JOB_READY"
100
101capture_events=
102
103_send_qemu_cmd $h "{ 'execute': 'block-job-complete',
104                                'arguments': {
105                                                'device': 'virtio0'
106                                              }
107                   }" '"status": "null"'
108
109echo
110echo === Performing Live Snapshot 2 ===
111echo
112
113# New live snapshot, new overlays as active layer
114_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync',
115                                'arguments': {
116                                                'device': 'virtio0',
117                                                'snapshot-file':'${TMP_SNAP2}',
118                                                'format': 'qcow2'
119                                              }
120                   }" "return"
121
122# success, all done
123echo "*** done"
124rm -f $seq.full
125status=0
126