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