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