xref: /openbmc/qemu/tests/qemu-iotests/144 (revision d5bc76fa)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick
38983b670SJeff Cody# Check live snapshot, followed by active commit, and another snapshot.
48983b670SJeff Cody#
58983b670SJeff Cody# This test is to catch the error case of BZ #1300209:
68983b670SJeff Cody# https://bugzilla.redhat.com/show_bug.cgi?id=1300209
78983b670SJeff Cody#
88983b670SJeff Cody# Copyright (C) 2016 Red Hat, Inc.
98983b670SJeff Cody#
108983b670SJeff Cody# This program is free software; you can redistribute it and/or modify
118983b670SJeff Cody# it under the terms of the GNU General Public License as published by
128983b670SJeff Cody# the Free Software Foundation; either version 2 of the License, or
138983b670SJeff Cody# (at your option) any later version.
148983b670SJeff Cody#
158983b670SJeff Cody# This program is distributed in the hope that it will be useful,
168983b670SJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of
178983b670SJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
188983b670SJeff Cody# GNU General Public License for more details.
198983b670SJeff Cody#
208983b670SJeff Cody# You should have received a copy of the GNU General Public License
218983b670SJeff Cody# along with this program.  If not, see <http://www.gnu.org/licenses/>.
228983b670SJeff Cody#
238983b670SJeff Cody
248983b670SJeff Cody# creator
2542a5009dSJohn Snowowner=codyprime@gmail.com
268983b670SJeff Cody
278983b670SJeff Codyseq=`basename $0`
288983b670SJeff Codyecho "QA output created by $seq"
298983b670SJeff Cody
308983b670SJeff Codystatus=1	# failure is the default!
318983b670SJeff Cody
328983b670SJeff CodyTMP_SNAP1=${TEST_DIR}/tmp.qcow2
338983b670SJeff CodyTMP_SNAP2=${TEST_DIR}/tmp2.qcow2
348983b670SJeff Cody
358983b670SJeff Cody_cleanup()
368983b670SJeff Cody{
378983b670SJeff Cody    _cleanup_qemu
38f91ecbd7SMax Reitz    for img in "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"; do
39f91ecbd7SMax Reitz        _rm_test_img "$img"
40f91ecbd7SMax Reitz    done
418983b670SJeff Cody}
428983b670SJeff Cody
438983b670SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15
448983b670SJeff Cody
458983b670SJeff Cody# get standard environment, filters and checks
468983b670SJeff Cody. ./common.rc
478983b670SJeff Cody. ./common.filter
488983b670SJeff Cody. ./common.qemu
498983b670SJeff Cody
508983b670SJeff Cody_supported_fmt qcow2
518983b670SJeff Cody_supported_proto file
528983b670SJeff Cody
538983b670SJeff Codysize=512M
548983b670SJeff Cody
558983b670SJeff Cody_make_test_img $size
568983b670SJeff Cody
578983b670SJeff Codyecho
588983b670SJeff Codyecho === Launching QEMU ===
598983b670SJeff Codyecho
608983b670SJeff Cody
618983b670SJeff Codyqemu_comm_method="qmp"
628983b670SJeff Cody_launch_qemu -drive file="${TEST_IMG}",if=virtio
638983b670SJeff Codyh=$QEMU_HANDLE
648983b670SJeff Cody
658983b670SJeff Cody
668983b670SJeff Codyecho
678983b670SJeff Codyecho === Performing Live Snapshot 1 ===
688983b670SJeff Codyecho
698983b670SJeff Cody
708983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return"
718983b670SJeff Cody
728983b670SJeff Cody
738983b670SJeff Cody# First live snapshot, new overlay as active layer
748983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync',
758983b670SJeff Cody                                'arguments': {
768983b670SJeff Cody                                             'device': 'virtio0',
778983b670SJeff Cody                                             'snapshot-file':'${TMP_SNAP1}',
788983b670SJeff Cody                                             'format': 'qcow2'
798983b670SJeff Cody                                             }
808983b670SJeff Cody                    }" "return"
818983b670SJeff Cody
828983b670SJeff Codyecho
838983b670SJeff Codyecho === Performing block-commit on active layer ===
848983b670SJeff Codyecho
858983b670SJeff Cody
86*d5bc76faSKevin Wolfcapture_events="BLOCK_JOB_READY JOB_STATUS_CHANGE"
87*d5bc76faSKevin Wolf
888983b670SJeff Cody# Block commit on active layer, push the new overlay into base
898983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'block-commit',
908983b670SJeff Cody                                'arguments': {
918983b670SJeff Cody                                                 'device': 'virtio0'
928983b670SJeff Cody                                              }
93*d5bc76faSKevin Wolf                    }" "return"
94*d5bc76faSKevin Wolf
95*d5bc76faSKevin Wolf_wait_event $h "JOB_STATUS_CHANGE"
96*d5bc76faSKevin Wolf_wait_event $h "JOB_STATUS_CHANGE"
97*d5bc76faSKevin Wolf_wait_event $h "JOB_STATUS_CHANGE"
98*d5bc76faSKevin Wolf
99*d5bc76faSKevin Wolf_wait_event $h "BLOCK_JOB_READY"
100*d5bc76faSKevin Wolf
101*d5bc76faSKevin Wolfcapture_events=
1028983b670SJeff Cody
1038983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'block-job-complete',
1048983b670SJeff Cody                                'arguments': {
1058983b670SJeff Cody                                                'device': 'virtio0'
1068983b670SJeff Cody                                              }
1071dac83f1SKevin Wolf                   }" '"status": "null"'
1088983b670SJeff Cody
1098983b670SJeff Codyecho
1108983b670SJeff Codyecho === Performing Live Snapshot 2 ===
1118983b670SJeff Codyecho
1128983b670SJeff Cody
1138983b670SJeff Cody# New live snapshot, new overlays as active layer
1148983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync',
1158983b670SJeff Cody                                'arguments': {
1168983b670SJeff Cody                                                'device': 'virtio0',
1178983b670SJeff Cody                                                'snapshot-file':'${TMP_SNAP2}',
1188983b670SJeff Cody                                                'format': 'qcow2'
1198983b670SJeff Cody                                              }
1208983b670SJeff Cody                   }" "return"
1218983b670SJeff Cody
1228983b670SJeff Cody# success, all done
1238983b670SJeff Codyecho "*** done"
1248983b670SJeff Codyrm -f $seq.full
1258983b670SJeff Codystatus=0
126