111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2*9dd003a9SVladimir 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 258983b670SJeff Codyowner=jcody@redhat.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 868983b670SJeff Cody# Block commit on active layer, push the new overlay into base 878983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'block-commit', 888983b670SJeff Cody 'arguments': { 898983b670SJeff Cody 'device': 'virtio0' 908983b670SJeff Cody } 918983b670SJeff Cody }" "READY" 928983b670SJeff Cody 938983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'block-job-complete', 948983b670SJeff Cody 'arguments': { 958983b670SJeff Cody 'device': 'virtio0' 968983b670SJeff Cody } 971dac83f1SKevin Wolf }" '"status": "null"' 988983b670SJeff Cody 998983b670SJeff Codyecho 1008983b670SJeff Codyecho === Performing Live Snapshot 2 === 1018983b670SJeff Codyecho 1028983b670SJeff Cody 1038983b670SJeff Cody# New live snapshot, new overlays as active layer 1048983b670SJeff Cody_send_qemu_cmd $h "{ 'execute': 'blockdev-snapshot-sync', 1058983b670SJeff Cody 'arguments': { 1068983b670SJeff Cody 'device': 'virtio0', 1078983b670SJeff Cody 'snapshot-file':'${TMP_SNAP2}', 1088983b670SJeff Cody 'format': 'qcow2' 1098983b670SJeff Cody } 1108983b670SJeff Cody }" "return" 1118983b670SJeff Cody 1128983b670SJeff Cody# success, all done 1138983b670SJeff Codyecho "*** done" 1148983b670SJeff Codyrm -f $seq.full 1158983b670SJeff Codystatus=0 116