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