xref: /openbmc/qemu/tests/qemu-iotests/110 (revision 8df686165bacb8b2e6c0cae0cd29fd36b0f243ef)
1527ab22aSMax Reitz#!/bin/bash
2527ab22aSMax Reitz#
3527ab22aSMax Reitz# Test case for relative backing file names in complex BDS trees
4527ab22aSMax Reitz#
5527ab22aSMax Reitz# Copyright (C) 2014 Red Hat, Inc.
6527ab22aSMax Reitz#
7527ab22aSMax Reitz# This program is free software; you can redistribute it and/or modify
8527ab22aSMax Reitz# it under the terms of the GNU General Public License as published by
9527ab22aSMax Reitz# the Free Software Foundation; either version 2 of the License, or
10527ab22aSMax Reitz# (at your option) any later version.
11527ab22aSMax Reitz#
12527ab22aSMax Reitz# This program is distributed in the hope that it will be useful,
13527ab22aSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
14527ab22aSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15527ab22aSMax Reitz# GNU General Public License for more details.
16527ab22aSMax Reitz#
17527ab22aSMax Reitz# You should have received a copy of the GNU General Public License
18527ab22aSMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19527ab22aSMax Reitz#
20527ab22aSMax Reitz
21527ab22aSMax Reitz# creator
22527ab22aSMax Reitzowner=mreitz@redhat.com
23527ab22aSMax Reitz
24527ab22aSMax Reitzseq="$(basename $0)"
25527ab22aSMax Reitzecho "QA output created by $seq"
26527ab22aSMax Reitz
27527ab22aSMax Reitzstatus=1	# failure is the default!
28527ab22aSMax Reitz
29527ab22aSMax Reitz_cleanup()
30527ab22aSMax Reitz{
31527ab22aSMax Reitz	_cleanup_test_img
32527ab22aSMax Reitz}
33527ab22aSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
34527ab22aSMax Reitz
35527ab22aSMax Reitz# get standard environment, filters and checks
36527ab22aSMax Reitz. ./common.rc
37527ab22aSMax Reitz. ./common.filter
38527ab22aSMax Reitz
39527ab22aSMax Reitz# Any format supporting backing files
40527ab22aSMax Reitz_supported_fmt qed qcow qcow2 vmdk
41527ab22aSMax Reitz_supported_proto file
42527ab22aSMax Reitz_supported_os Linux
43527ab22aSMax Reitz_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
44527ab22aSMax Reitz
45527ab22aSMax ReitzTEST_IMG_REL=$(basename "$TEST_IMG")
46527ab22aSMax Reitz
47527ab22aSMax Reitzecho
48527ab22aSMax Reitzecho '=== Reconstructable filename ==='
49527ab22aSMax Reitzecho
50527ab22aSMax Reitz
51527ab22aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img 64M
52527ab22aSMax Reitz_make_test_img -b "$TEST_IMG_REL.base" 64M
53527ab22aSMax Reitz# qemu should be able to reconstruct the filename, so relative backing names
54527ab22aSMax Reitz# should work
55527ab22aSMax ReitzTEST_IMG="json:{'driver':'$IMGFMT','file':{'driver':'file','filename':'$TEST_IMG'}}" \
56527ab22aSMax Reitz    _img_info | _filter_img_info
57527ab22aSMax Reitz
58527ab22aSMax Reitzecho
59527ab22aSMax Reitzecho '=== Non-reconstructable filename ==='
60527ab22aSMax Reitzecho
61527ab22aSMax Reitz
62527ab22aSMax Reitz# Across blkdebug without a config file, you cannot reconstruct filenames, so
63*8df68616SMax Reitz# qemu is incapable of knowing the directory of the top image from the filename
64*8df68616SMax Reitz# alone. However, using bdrv_dirname(), it should still work.
65527ab22aSMax ReitzTEST_IMG="json:{
66527ab22aSMax Reitz    'driver': '$IMGFMT',
67527ab22aSMax Reitz    'file': {
68527ab22aSMax Reitz        'driver': 'blkdebug',
69527ab22aSMax Reitz        'image': {
70527ab22aSMax Reitz            'driver': 'file',
71527ab22aSMax Reitz            'filename': '$TEST_IMG'
72527ab22aSMax Reitz        },
73527ab22aSMax Reitz        'set-state': [
74527ab22aSMax Reitz            {
75527ab22aSMax Reitz                'event': 'read_aio',
76527ab22aSMax Reitz                'new_state': 42
77527ab22aSMax Reitz            }
78527ab22aSMax Reitz        ]
79527ab22aSMax Reitz    }
80527ab22aSMax Reitz}" _img_info | _filter_img_info
81527ab22aSMax Reitz
82527ab22aSMax Reitzecho
83527ab22aSMax Reitzecho '=== Backing name is always relative to the backed image ==='
84527ab22aSMax Reitzecho
85527ab22aSMax Reitz
86527ab22aSMax Reitz# omit the image size; it should work anyway
87527ab22aSMax Reitz_make_test_img -b "$TEST_IMG_REL.base"
88527ab22aSMax Reitz
89527ab22aSMax Reitz
90527ab22aSMax Reitz# success, all done
91527ab22aSMax Reitzecho '*** done'
92527ab22aSMax Reitzrm -f $seq.full
93527ab22aSMax Reitzstatus=0
94