xref: /openbmc/qemu/tests/qemu-iotests/110 (revision c0625e80925302c449bb3f7a7ba6eb213da7c1e2)
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
32*c0625e80SMax Reitz        rm -f "$TEST_IMG.copy"
33527ab22aSMax Reitz}
34527ab22aSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15
35527ab22aSMax Reitz
36527ab22aSMax Reitz# get standard environment, filters and checks
37527ab22aSMax Reitz. ./common.rc
38527ab22aSMax Reitz. ./common.filter
39527ab22aSMax Reitz
40527ab22aSMax Reitz# Any format supporting backing files
41527ab22aSMax Reitz_supported_fmt qed qcow qcow2 vmdk
42527ab22aSMax Reitz_supported_proto file
43527ab22aSMax Reitz_supported_os Linux
44527ab22aSMax Reitz_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
45527ab22aSMax Reitz
46527ab22aSMax ReitzTEST_IMG_REL=$(basename "$TEST_IMG")
47527ab22aSMax Reitz
48527ab22aSMax Reitzecho
49527ab22aSMax Reitzecho '=== Reconstructable filename ==='
50527ab22aSMax Reitzecho
51527ab22aSMax Reitz
52527ab22aSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img 64M
53527ab22aSMax Reitz_make_test_img -b "$TEST_IMG_REL.base" 64M
54527ab22aSMax Reitz# qemu should be able to reconstruct the filename, so relative backing names
55527ab22aSMax Reitz# should work
56527ab22aSMax ReitzTEST_IMG="json:{'driver':'$IMGFMT','file':{'driver':'file','filename':'$TEST_IMG'}}" \
57527ab22aSMax Reitz    _img_info | _filter_img_info
58527ab22aSMax Reitz
59527ab22aSMax Reitzecho
60527ab22aSMax Reitzecho '=== Non-reconstructable filename ==='
61527ab22aSMax Reitzecho
62527ab22aSMax Reitz
63527ab22aSMax Reitz# Across blkdebug without a config file, you cannot reconstruct filenames, so
648df68616SMax Reitz# qemu is incapable of knowing the directory of the top image from the filename
658df68616SMax Reitz# alone. However, using bdrv_dirname(), it should still work.
66527ab22aSMax ReitzTEST_IMG="json:{
67527ab22aSMax Reitz    'driver': '$IMGFMT',
68527ab22aSMax Reitz    'file': {
69527ab22aSMax Reitz        'driver': 'blkdebug',
70527ab22aSMax Reitz        'image': {
71527ab22aSMax Reitz            'driver': 'file',
72527ab22aSMax Reitz            'filename': '$TEST_IMG'
73527ab22aSMax Reitz        },
74527ab22aSMax Reitz        'set-state': [
75527ab22aSMax Reitz            {
76527ab22aSMax Reitz                'event': 'read_aio',
77527ab22aSMax Reitz                'new_state': 42
78527ab22aSMax Reitz            }
79527ab22aSMax Reitz        ]
80527ab22aSMax Reitz    }
81527ab22aSMax Reitz}" _img_info | _filter_img_info
82527ab22aSMax Reitz
83527ab22aSMax Reitzecho
84527ab22aSMax Reitzecho '=== Backing name is always relative to the backed image ==='
85527ab22aSMax Reitzecho
86527ab22aSMax Reitz
87527ab22aSMax Reitz# omit the image size; it should work anyway
88527ab22aSMax Reitz_make_test_img -b "$TEST_IMG_REL.base"
89527ab22aSMax Reitz
90*c0625e80SMax Reitzecho
91*c0625e80SMax Reitzecho '=== Nodes without a common directory ==='
92*c0625e80SMax Reitzecho
93*c0625e80SMax Reitz
94*c0625e80SMax Reitzcp "$TEST_IMG" "$TEST_IMG.copy"
95*c0625e80SMax Reitz
96*c0625e80SMax Reitz# Should inform us that the actual path of the backing file cannot be determined
97*c0625e80SMax ReitzTEST_IMG="json:{
98*c0625e80SMax Reitz    'driver': '$IMGFMT',
99*c0625e80SMax Reitz    'file': {
100*c0625e80SMax Reitz        'driver': 'quorum',
101*c0625e80SMax Reitz        'vote-threshold': 1,
102*c0625e80SMax Reitz        'children': [
103*c0625e80SMax Reitz            {
104*c0625e80SMax Reitz                'driver': 'file',
105*c0625e80SMax Reitz                'filename': '$TEST_IMG'
106*c0625e80SMax Reitz            },
107*c0625e80SMax Reitz            {
108*c0625e80SMax Reitz                'driver': 'file',
109*c0625e80SMax Reitz                'filename': '$TEST_IMG.copy'
110*c0625e80SMax Reitz            }
111*c0625e80SMax Reitz        ]
112*c0625e80SMax Reitz    }
113*c0625e80SMax Reitz}" _img_info | _filter_img_info
114*c0625e80SMax Reitz
115527ab22aSMax Reitz
116527ab22aSMax Reitz# success, all done
117527ab22aSMax Reitzecho '*** done'
118527ab22aSMax Reitzrm -f $seq.full
119527ab22aSMax Reitzstatus=0
120