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