1*256e3b63SJeff Cody#!/bin/bash 2*256e3b63SJeff Cody# 3*256e3b63SJeff Cody# Test QAPI commands looking up protocol based images with relative 4*256e3b63SJeff Cody# filename backing strings 5*256e3b63SJeff Cody# 6*256e3b63SJeff Cody# Copyright (C) 2017 Red Hat, Inc. 7*256e3b63SJeff Cody# 8*256e3b63SJeff Cody# This program is free software; you can redistribute it and/or modify 9*256e3b63SJeff Cody# it under the terms of the GNU General Public License as published by 10*256e3b63SJeff Cody# the Free Software Foundation; either version 2 of the License, or 11*256e3b63SJeff Cody# (at your option) any later version. 12*256e3b63SJeff Cody# 13*256e3b63SJeff Cody# This program is distributed in the hope that it will be useful, 14*256e3b63SJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of 15*256e3b63SJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*256e3b63SJeff Cody# GNU General Public License for more details. 17*256e3b63SJeff Cody# 18*256e3b63SJeff Cody# You should have received a copy of the GNU General Public License 19*256e3b63SJeff Cody# along with this program. If not, see <http://www.gnu.org/licenses/>. 20*256e3b63SJeff Cody# 21*256e3b63SJeff Cody# creator 22*256e3b63SJeff Codyowner=jcody@redhat.com 23*256e3b63SJeff Cody 24*256e3b63SJeff Codyseq=`basename $0` 25*256e3b63SJeff Codyecho "QA output created by $seq" 26*256e3b63SJeff Cody 27*256e3b63SJeff Codyhere=`pwd` 28*256e3b63SJeff Codystatus=1 # failure is the default! 29*256e3b63SJeff Cody 30*256e3b63SJeff Cody_cleanup() 31*256e3b63SJeff Cody{ 32*256e3b63SJeff Cody _cleanup_qemu 33*256e3b63SJeff Cody rm -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1" 34*256e3b63SJeff Cody _cleanup_test_img 35*256e3b63SJeff Cody} 36*256e3b63SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15 37*256e3b63SJeff Cody 38*256e3b63SJeff Cody# get standard environment, filters and checks 39*256e3b63SJeff Cody. ./common.rc 40*256e3b63SJeff Cody. ./common.filter 41*256e3b63SJeff Cody. ./common.qemu 42*256e3b63SJeff Cody 43*256e3b63SJeff Cody_supported_fmt qcow2 44*256e3b63SJeff Cody_supported_proto nfs 45*256e3b63SJeff Cody_supported_os Linux 46*256e3b63SJeff Cody 47*256e3b63SJeff Codysize=100M 48*256e3b63SJeff Cody 49*256e3b63SJeff CodyBASE_IMG="${TEST_DIR}/image.base" 50*256e3b63SJeff CodyTOP_IMG="${TEST_DIR}/image.snp1" 51*256e3b63SJeff Cody 52*256e3b63SJeff CodyTEST_IMG="${BASE_IMG}" _make_test_img $size 53*256e3b63SJeff Cody 54*256e3b63SJeff CodyTEST_IMG="${TOP_IMG}" _make_test_img $size 55*256e3b63SJeff Cody 56*256e3b63SJeff Codyecho 57*256e3b63SJeff Codyecho === Running QEMU, using block-stream to find backing image === 58*256e3b63SJeff Codyecho 59*256e3b63SJeff Cody 60*256e3b63SJeff Codyqemu_comm_method="qmp" 61*256e3b63SJeff Cody_launch_qemu -drive file="${BASE_IMG}",if=virtio,id=disk2 62*256e3b63SJeff Codyh=$QEMU_HANDLE 63*256e3b63SJeff Cody 64*256e3b63SJeff Cody_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" 65*256e3b63SJeff Cody 66*256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': { 67*256e3b63SJeff Cody 'device': 'disk2', 68*256e3b63SJeff Cody 'format': '${IMGFMT}', 69*256e3b63SJeff Cody 'mode': 'existing', 70*256e3b63SJeff Cody 'snapshot-file': '${TOP_IMG}', 71*256e3b63SJeff Cody 'snapshot-node-name': 'snp1' 72*256e3b63SJeff Cody }, 73*256e3b63SJeff Cody 'execute': 'blockdev-snapshot-sync' 74*256e3b63SJeff Cody }" "return" 75*256e3b63SJeff Cody 76*256e3b63SJeff Cody 77*256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': { 78*256e3b63SJeff Cody 'backing-file': 'image.base', 79*256e3b63SJeff Cody 'device': 'disk2', 80*256e3b63SJeff Cody 'image-node-name': 'snp1' 81*256e3b63SJeff Cody }, 82*256e3b63SJeff Cody 'execute': 'change-backing-file' 83*256e3b63SJeff Cody }" "return" 84*256e3b63SJeff Cody 85*256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': { 86*256e3b63SJeff Cody 'base': '${BASE_IMG}', 87*256e3b63SJeff Cody 'device': 'disk2' 88*256e3b63SJeff Cody }, 89*256e3b63SJeff Cody 'execute': 'block-stream' 90*256e3b63SJeff Cody }" "BLOCK_JOB_COMPLETED" 91*256e3b63SJeff Cody 92*256e3b63SJeff Cody_cleanup_qemu 93*256e3b63SJeff Cody 94*256e3b63SJeff Cody# success, all done 95*256e3b63SJeff Codyecho "*** done" 96*256e3b63SJeff Codyrm -f $seq.full 97*256e3b63SJeff Codystatus=0 98