xref: /openbmc/qemu/tests/qemu-iotests/110 (revision 527ab22a2a268421564cfba3409d081aee22c22b)
1*527ab22aSMax Reitz#!/bin/bash
2*527ab22aSMax Reitz#
3*527ab22aSMax Reitz# Test case for relative backing file names in complex BDS trees
4*527ab22aSMax Reitz#
5*527ab22aSMax Reitz# Copyright (C) 2014 Red Hat, Inc.
6*527ab22aSMax Reitz#
7*527ab22aSMax Reitz# This program is free software; you can redistribute it and/or modify
8*527ab22aSMax Reitz# it under the terms of the GNU General Public License as published by
9*527ab22aSMax Reitz# the Free Software Foundation; either version 2 of the License, or
10*527ab22aSMax Reitz# (at your option) any later version.
11*527ab22aSMax Reitz#
12*527ab22aSMax Reitz# This program is distributed in the hope that it will be useful,
13*527ab22aSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14*527ab22aSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*527ab22aSMax Reitz# GNU General Public License for more details.
16*527ab22aSMax Reitz#
17*527ab22aSMax Reitz# You should have received a copy of the GNU General Public License
18*527ab22aSMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19*527ab22aSMax Reitz#
20*527ab22aSMax Reitz
21*527ab22aSMax Reitz# creator
22*527ab22aSMax Reitzowner=mreitz@redhat.com
23*527ab22aSMax Reitz
24*527ab22aSMax Reitzseq="$(basename $0)"
25*527ab22aSMax Reitzecho "QA output created by $seq"
26*527ab22aSMax Reitz
27*527ab22aSMax Reitzhere="$PWD"
28*527ab22aSMax Reitztmp=/tmp/$$
29*527ab22aSMax Reitzstatus=1	# failure is the default!
30*527ab22aSMax Reitz
31*527ab22aSMax Reitz_cleanup()
32*527ab22aSMax Reitz{
33*527ab22aSMax Reitz	_cleanup_test_img
34*527ab22aSMax Reitz}
35*527ab22aSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
36*527ab22aSMax Reitz
37*527ab22aSMax Reitz# get standard environment, filters and checks
38*527ab22aSMax Reitz. ./common.rc
39*527ab22aSMax Reitz. ./common.filter
40*527ab22aSMax Reitz
41*527ab22aSMax Reitz# Any format supporting backing files
42*527ab22aSMax Reitz_supported_fmt qed qcow qcow2 vmdk
43*527ab22aSMax Reitz_supported_proto file
44*527ab22aSMax Reitz_supported_os Linux
45*527ab22aSMax Reitz_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
46*527ab22aSMax Reitz
47*527ab22aSMax ReitzTEST_IMG_REL=$(basename "$TEST_IMG")
48*527ab22aSMax Reitz
49*527ab22aSMax Reitzecho
50*527ab22aSMax Reitzecho '=== Reconstructable filename ==='
51*527ab22aSMax Reitzecho
52*527ab22aSMax Reitz
53*527ab22aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img 64M
54*527ab22aSMax Reitz_make_test_img -b "$TEST_IMG_REL.base" 64M
55*527ab22aSMax Reitz# qemu should be able to reconstruct the filename, so relative backing names
56*527ab22aSMax Reitz# should work
57*527ab22aSMax ReitzTEST_IMG="json:{'driver':'$IMGFMT','file':{'driver':'file','filename':'$TEST_IMG'}}" \
58*527ab22aSMax Reitz    _img_info | _filter_img_info
59*527ab22aSMax Reitz
60*527ab22aSMax Reitzecho
61*527ab22aSMax Reitzecho '=== Non-reconstructable filename ==='
62*527ab22aSMax Reitzecho
63*527ab22aSMax Reitz
64*527ab22aSMax Reitz# Across blkdebug without a config file, you cannot reconstruct filenames, so
65*527ab22aSMax Reitz# qemu is incapable of knowing the directory of the top image
66*527ab22aSMax ReitzTEST_IMG="json:{
67*527ab22aSMax Reitz    'driver': '$IMGFMT',
68*527ab22aSMax Reitz    'file': {
69*527ab22aSMax Reitz        'driver': 'blkdebug',
70*527ab22aSMax Reitz        'image': {
71*527ab22aSMax Reitz            'driver': 'file',
72*527ab22aSMax Reitz            'filename': '$TEST_IMG'
73*527ab22aSMax Reitz        },
74*527ab22aSMax Reitz        'set-state': [
75*527ab22aSMax Reitz            {
76*527ab22aSMax Reitz                'event': 'read_aio',
77*527ab22aSMax Reitz                'new_state': 42
78*527ab22aSMax Reitz            }
79*527ab22aSMax Reitz        ]
80*527ab22aSMax Reitz    }
81*527ab22aSMax Reitz}" _img_info | _filter_img_info
82*527ab22aSMax Reitz
83*527ab22aSMax Reitzecho
84*527ab22aSMax Reitzecho '=== Backing name is always relative to the backed image ==='
85*527ab22aSMax Reitzecho
86*527ab22aSMax Reitz
87*527ab22aSMax Reitz# omit the image size; it should work anyway
88*527ab22aSMax Reitz_make_test_img -b "$TEST_IMG_REL.base"
89*527ab22aSMax Reitz
90*527ab22aSMax Reitz
91*527ab22aSMax Reitz# success, all done
92*527ab22aSMax Reitzecho '*** done'
93*527ab22aSMax Reitzrm -f $seq.full
94*527ab22aSMax Reitzstatus=0
95