xref: /openbmc/qemu/tests/qemu-iotests/173 (revision 11a82d14)
1*11a82d14SPhilippe 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_supported_os Linux
45256e3b63SJeff Cody
46256e3b63SJeff Codysize=100M
47256e3b63SJeff Cody
48256e3b63SJeff CodyBASE_IMG="${TEST_DIR}/image.base"
49256e3b63SJeff CodyTOP_IMG="${TEST_DIR}/image.snp1"
50256e3b63SJeff Cody
51256e3b63SJeff CodyTEST_IMG="${BASE_IMG}" _make_test_img $size
52256e3b63SJeff Cody
53256e3b63SJeff CodyTEST_IMG="${TOP_IMG}" _make_test_img $size
54256e3b63SJeff Cody
55256e3b63SJeff Codyecho
56256e3b63SJeff Codyecho === Running QEMU, using block-stream to find backing image ===
57256e3b63SJeff Codyecho
58256e3b63SJeff Cody
59256e3b63SJeff Codyqemu_comm_method="qmp"
60256e3b63SJeff Cody_launch_qemu -drive file="${BASE_IMG}",if=virtio,id=disk2
61256e3b63SJeff Codyh=$QEMU_HANDLE
62256e3b63SJeff Cody
63256e3b63SJeff Cody_send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" "return"
64256e3b63SJeff Cody
65256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': {
66256e3b63SJeff Cody                        'device': 'disk2',
67256e3b63SJeff Cody                        'format': '${IMGFMT}',
68256e3b63SJeff Cody                        'mode': 'existing',
69256e3b63SJeff Cody                        'snapshot-file': '${TOP_IMG}',
70256e3b63SJeff Cody                        'snapshot-node-name': 'snp1'
71256e3b63SJeff Cody                     },
72256e3b63SJeff Cody                     'execute': 'blockdev-snapshot-sync'
73256e3b63SJeff Cody                   }" "return"
74256e3b63SJeff Cody
75256e3b63SJeff Cody
76256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': {
77256e3b63SJeff Cody                        'backing-file': 'image.base',
78256e3b63SJeff Cody                        'device': 'disk2',
79256e3b63SJeff Cody                        'image-node-name': 'snp1'
80256e3b63SJeff Cody                     },
81256e3b63SJeff Cody                     'execute': 'change-backing-file'
82256e3b63SJeff Cody                   }" "return"
83256e3b63SJeff Cody
84256e3b63SJeff Cody_send_qemu_cmd $h "{ 'arguments': {
85256e3b63SJeff Cody                        'base': '${BASE_IMG}',
86256e3b63SJeff Cody                        'device': 'disk2'
87256e3b63SJeff Cody                      },
88256e3b63SJeff Cody                      'execute': 'block-stream'
89256e3b63SJeff Cody                   }" "BLOCK_JOB_COMPLETED"
90256e3b63SJeff Cody
91256e3b63SJeff Cody_cleanup_qemu
92256e3b63SJeff Cody
93256e3b63SJeff Cody# success, all done
94256e3b63SJeff Codyecho "*** done"
95256e3b63SJeff Codyrm -f $seq.full
96256e3b63SJeff Codystatus=0
97