xref: /openbmc/qemu/tests/qemu-iotests/144 (revision 11a82d14)
1*11a82d14SPhilippe 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
378983b670SJeff Cody    rm -f "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"
388983b670SJeff Cody}
398983b670SJeff Cody
408983b670SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15
418983b670SJeff Cody
428983b670SJeff Cody# get standard environment, filters and checks
438983b670SJeff Cody. ./common.rc
448983b670SJeff Cody. ./common.filter
458983b670SJeff Cody. ./common.qemu
468983b670SJeff Cody
478983b670SJeff Cody_supported_fmt qcow2
488983b670SJeff Cody_supported_proto file
498983b670SJeff Cody_supported_os Linux
508983b670SJeff Cody
518983b670SJeff Codysize=512M
528983b670SJeff Cody
538983b670SJeff Cody_make_test_img $size
548983b670SJeff Cody
558983b670SJeff Codyecho
568983b670SJeff Codyecho === Launching QEMU ===
578983b670SJeff Codyecho
588983b670SJeff Cody
598983b670SJeff Codyqemu_comm_method="qmp"
608983b670SJeff Cody_launch_qemu -drive file="${TEST_IMG}",if=virtio
618983b670SJeff Codyh=$QEMU_HANDLE
628983b670SJeff Cody
638983b670SJeff Cody
648983b670SJeff Codyecho
658983b670SJeff Codyecho === Performing Live Snapshot 1 ===
668983b670SJeff Codyecho
678983b670SJeff Cody
688983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return"
698983b670SJeff Cody
708983b670SJeff Cody
718983b670SJeff Cody# First live snapshot, new overlay as active layer
728983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync',
738983b670SJeff Cody                                'arguments': {
748983b670SJeff Cody                                             'device': 'virtio0',
758983b670SJeff Cody                                             'snapshot-file':'${TMP_SNAP1}',
768983b670SJeff Cody                                             'format': 'qcow2'
778983b670SJeff Cody                                             }
788983b670SJeff Cody                    }" "return"
798983b670SJeff Cody
808983b670SJeff Codyecho
818983b670SJeff Codyecho === Performing block-commit on active layer ===
828983b670SJeff Codyecho
838983b670SJeff Cody
848983b670SJeff Cody# Block commit on active layer, push the new overlay into base
858983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'block-commit',
868983b670SJeff Cody                                'arguments': {
878983b670SJeff Cody                                                 'device': 'virtio0'
888983b670SJeff Cody                                              }
898983b670SJeff Cody                    }" "READY"
908983b670SJeff Cody
918983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'block-job-complete',
928983b670SJeff Cody                                'arguments': {
938983b670SJeff Cody                                                'device': 'virtio0'
948983b670SJeff Cody                                              }
951dac83f1SKevin Wolf                   }" '"status": "null"'
968983b670SJeff Cody
978983b670SJeff Codyecho
988983b670SJeff Codyecho === Performing Live Snapshot 2 ===
998983b670SJeff Codyecho
1008983b670SJeff Cody
1018983b670SJeff Cody# New live snapshot, new overlays as active layer
1028983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync',
1038983b670SJeff Cody                                'arguments': {
1048983b670SJeff Cody                                                'device': 'virtio0',
1058983b670SJeff Cody                                                'snapshot-file':'${TMP_SNAP2}',
1068983b670SJeff Cody                                                'format': 'qcow2'
1078983b670SJeff Cody                                              }
1088983b670SJeff Cody                   }" "return"
1098983b670SJeff Cody
1108983b670SJeff Cody# success, all done
1118983b670SJeff Codyecho "*** done"
1128983b670SJeff Codyrm -f $seq.full
1138983b670SJeff Codystatus=0
114