111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2256e3b63SJeff Cody# 3256e3b63SJeff Cody# Test QAPI commands looking up protocol based images with relative 4256e3b63SJeff Cody# filename backing strings 5256e3b63SJeff Cody# 6256e3b63SJeff Cody# Copyright (C) 2017 Red Hat, Inc. 7256e3b63SJeff Cody# 8256e3b63SJeff Cody# This program is free software; you can redistribute it and/or modify 9256e3b63SJeff Cody# it under the terms of the GNU General Public License as published by 10256e3b63SJeff Cody# the Free Software Foundation; either version 2 of the License, or 11256e3b63SJeff Cody# (at your option) any later version. 12256e3b63SJeff Cody# 13256e3b63SJeff Cody# This program is distributed in the hope that it will be useful, 14256e3b63SJeff Cody# but WITHOUT ANY WARRANTY; without even the implied warranty of 15256e3b63SJeff Cody# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16256e3b63SJeff Cody# GNU General Public License for more details. 17256e3b63SJeff Cody# 18256e3b63SJeff Cody# You should have received a copy of the GNU General Public License 19256e3b63SJeff Cody# along with this program. If not, see <http://www.gnu.org/licenses/>. 20256e3b63SJeff Cody# 21256e3b63SJeff Cody# creator 22256e3b63SJeff Codyowner=jcody@redhat.com 23256e3b63SJeff Cody 24256e3b63SJeff Codyseq=`basename $0` 25256e3b63SJeff Codyecho "QA output created by $seq" 26256e3b63SJeff Cody 27256e3b63SJeff Codystatus=1 # failure is the default! 28256e3b63SJeff Cody 29256e3b63SJeff Cody_cleanup() 30256e3b63SJeff Cody{ 31256e3b63SJeff Cody _cleanup_qemu 32256e3b63SJeff Cody rm -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1" 33256e3b63SJeff Cody _cleanup_test_img 34256e3b63SJeff Cody} 35256e3b63SJeff Codytrap "_cleanup; exit \$status" 0 1 2 3 15 36256e3b63SJeff Cody 37256e3b63SJeff Cody# get standard environment, filters and checks 38256e3b63SJeff Cody. ./common.rc 39256e3b63SJeff Cody. ./common.filter 40256e3b63SJeff Cody. ./common.qemu 41256e3b63SJeff Cody 42256e3b63SJeff Cody_supported_fmt qcow2 43256e3b63SJeff Cody_supported_proto nfs 44256e3b63SJeff Cody 45256e3b63SJeff Codysize=100M 46256e3b63SJeff Cody 47256e3b63SJeff CodyBASE_IMG="${TEST_DIR}/image.base" 48256e3b63SJeff CodyTOP_IMG="${TEST_DIR}/image.snp1" 49256e3b63SJeff Cody 50*509e91c1SEric BlakeTEST_IMG_FILE="${BASE_IMG}" _make_test_img $size 51256e3b63SJeff Cody 52*509e91c1SEric BlakeTEST_IMG_FILE="${TOP_IMG}" _make_test_img $size 53256e3b63SJeff Cody 54256e3b63SJeff Codyecho 55256e3b63SJeff Codyecho === Running QEMU, using block-stream to find backing image === 56256e3b63SJeff Codyecho 57256e3b63SJeff Cody 58256e3b63SJeff Codyqemu_comm_method="qmp" 59256e3b63SJeff Cody_launch_qemu -drive file="${BASE_IMG}",if=virtio,id=disk2 60256e3b63SJeff Codyh=$QEMU_HANDLE 61256e3b63SJeff Cody 62256e3b63SJeff Cody_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return" 63256e3b63SJeff Cody 64256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': { 65256e3b63SJeff Cody 'device': 'disk2', 66256e3b63SJeff Cody 'format': '${IMGFMT}', 67256e3b63SJeff Cody 'mode': 'existing', 68256e3b63SJeff Cody 'snapshot-file': '${TOP_IMG}', 69256e3b63SJeff Cody 'snapshot-node-name': 'snp1' 70256e3b63SJeff Cody }, 71256e3b63SJeff Cody 'execute': 'blockdev-snapshot-sync' 72256e3b63SJeff Cody }" "return" 73256e3b63SJeff Cody 74256e3b63SJeff Cody 75256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': { 76256e3b63SJeff Cody 'backing-file': 'image.base', 77256e3b63SJeff Cody 'device': 'disk2', 78256e3b63SJeff Cody 'image-node-name': 'snp1' 79256e3b63SJeff Cody }, 80256e3b63SJeff Cody 'execute': 'change-backing-file' 81256e3b63SJeff Cody }" "return" 82256e3b63SJeff Cody 83256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': { 84256e3b63SJeff Cody 'base': '${BASE_IMG}', 85256e3b63SJeff Cody 'device': 'disk2' 86256e3b63SJeff Cody }, 87256e3b63SJeff Cody 'execute': 'block-stream' 88256e3b63SJeff Cody }" "BLOCK_JOB_COMPLETED" 89256e3b63SJeff Cody 90256e3b63SJeff Cody_cleanup_qemu 91256e3b63SJeff Cody 92256e3b63SJeff Cody# success, all done 93256e3b63SJeff Codyecho "*** done" 94256e3b63SJeff Codyrm -f $seq.full 95256e3b63SJeff Codystatus=0 96