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