xref: /openbmc/qemu/tests/qemu-iotests/126 (revision 42a5009d)
111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto backing
36f55dfa4SMax Reitz#
46f55dfa4SMax Reitz# Tests handling of colons in filenames (which may be confused with protocol
56f55dfa4SMax Reitz# prefixes)
66f55dfa4SMax Reitz#
76f55dfa4SMax Reitz# Copyright (C) 2017 Red Hat, Inc.
86f55dfa4SMax Reitz#
96f55dfa4SMax Reitz# This program is free software; you can redistribute it and/or modify
106f55dfa4SMax Reitz# it under the terms of the GNU General Public License as published by
116f55dfa4SMax Reitz# the Free Software Foundation; either version 2 of the License, or
126f55dfa4SMax Reitz# (at your option) any later version.
136f55dfa4SMax Reitz#
146f55dfa4SMax Reitz# This program is distributed in the hope that it will be useful,
156f55dfa4SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of
166f55dfa4SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
176f55dfa4SMax Reitz# GNU General Public License for more details.
186f55dfa4SMax Reitz#
196f55dfa4SMax Reitz# You should have received a copy of the GNU General Public License
206f55dfa4SMax Reitz# along with this program.  If not, see <http://www.gnu.org/licenses/>.
216f55dfa4SMax Reitz#
226f55dfa4SMax Reitz
236f55dfa4SMax Reitz# creator
24*42a5009dSJohn Snowowner=hreitz@redhat.com
256f55dfa4SMax Reitz
266f55dfa4SMax Reitzseq="$(basename $0)"
276f55dfa4SMax Reitzecho "QA output created by $seq"
286f55dfa4SMax Reitz
296f55dfa4SMax Reitzstatus=1	# failure is the default!
306f55dfa4SMax Reitz
316f55dfa4SMax Reitz# get standard environment, filters and checks
326f55dfa4SMax Reitz. ./common.rc
336f55dfa4SMax Reitz. ./common.filter
346f55dfa4SMax Reitz
356f55dfa4SMax Reitz# Needs backing file support
366f55dfa4SMax Reitz_supported_fmt qcow qcow2 qed vmdk
3739af39c4SMax Reitz_unsupported_imgopts "subformat=monolithicFlat" \
3839af39c4SMax Reitz                     "subformat=twoGbMaxExtentFlat"
396f55dfa4SMax Reitz# This is the default protocol (and we want to test the difference between
406f55dfa4SMax Reitz# colons which separate a protocol prefix from the rest and colons which are
416f55dfa4SMax Reitz# just part of the filename, so we cannot test protocols which require a prefix)
426f55dfa4SMax Reitz_supported_proto file
436f55dfa4SMax Reitz
446f55dfa4SMax Reitzecho
456f55dfa4SMax Reitzecho '=== Testing plain files ==='
466f55dfa4SMax Reitzecho
476f55dfa4SMax Reitz
486f55dfa4SMax Reitz# A colon after a slash is not a protocol prefix separator
496f55dfa4SMax ReitzTEST_IMG="$TEST_DIR/a:b.$IMGFMT" _make_test_img 64M
506f55dfa4SMax Reitz_rm_test_img "$TEST_DIR/a:b.$IMGFMT"
516f55dfa4SMax Reitz
526f55dfa4SMax Reitz# But if you want to be really sure, you can do this
536f55dfa4SMax ReitzTEST_IMG="file:$TEST_DIR/a:b.$IMGFMT" _make_test_img 64M
546f55dfa4SMax Reitz_rm_test_img "$TEST_DIR/a:b.$IMGFMT"
556f55dfa4SMax Reitz
566f55dfa4SMax Reitz
576f55dfa4SMax Reitzecho
586f55dfa4SMax Reitzecho '=== Testing relative backing filename resolution ==='
596f55dfa4SMax Reitzecho
606f55dfa4SMax Reitz
616f55dfa4SMax ReitzBASE_IMG="$TEST_DIR/image:base.$IMGFMT"
626f55dfa4SMax ReitzTOP_IMG="$TEST_DIR/image:top.$IMGFMT"
636f55dfa4SMax Reitz
646f55dfa4SMax ReitzTEST_IMG=$BASE_IMG _make_test_img 64M
65b66ff2c2SEric BlakeTEST_IMG=$TOP_IMG _make_test_img -b ./image:base.$IMGFMT -F $IMGFMT
666f55dfa4SMax Reitz
671278dce7SMax Reitz# (1) The default cluster size depends on the image format
681278dce7SMax Reitz# (2) vmdk only supports vmdk backing files, so it always reports the
691278dce7SMax Reitz#     format of its backing file as such (but neither it nor qcow
701278dce7SMax Reitz#     support the backing_fmt creation option, so we cannot use that to
711278dce7SMax Reitz#     harmonize the output across all image formats this test supports)
721278dce7SMax ReitzTEST_IMG=$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file format'
736f55dfa4SMax Reitz
746f55dfa4SMax Reitz_rm_test_img "$BASE_IMG"
756f55dfa4SMax Reitz_rm_test_img "$TOP_IMG"
766f55dfa4SMax Reitz
776f55dfa4SMax Reitz
786f55dfa4SMax Reitz# Do another test where we access both top and base without any slash in them
796f55dfa4SMax Reitzecho
806f55dfa4SMax Reitzpushd "$TEST_DIR" >/dev/null
816f55dfa4SMax Reitz
826f55dfa4SMax ReitzBASE_IMG="base.$IMGFMT"
836f55dfa4SMax ReitzTOP_IMG="file:image:top.$IMGFMT"
846f55dfa4SMax Reitz
856f55dfa4SMax ReitzTEST_IMG=$BASE_IMG _make_test_img 64M
86b66ff2c2SEric BlakeTEST_IMG=$TOP_IMG _make_test_img -b "$BASE_IMG" -F $IMGFMT
876f55dfa4SMax Reitz
881278dce7SMax ReitzTEST_IMG=$TOP_IMG _img_info | grep -ve 'cluster_size' -e 'backing file format'
896f55dfa4SMax Reitz
906f55dfa4SMax Reitz_rm_test_img "$BASE_IMG"
916f55dfa4SMax Reitz_rm_test_img "image:top.$IMGFMT"
926f55dfa4SMax Reitz
936f55dfa4SMax Reitzpopd >/dev/null
946f55dfa4SMax Reitz
956f55dfa4SMax Reitz# Note that we could also do the same test with BASE_IMG=file:image:base.$IMGFMT
966f55dfa4SMax Reitz# -- but behavior for that case is a bit strange. Protocol-prefixed paths are
976f55dfa4SMax Reitz# in a sense always absolute paths, so such paths will never be combined with
986f55dfa4SMax Reitz# the path of the overlay. But since "image:base.$IMGFMT" is actually a
996f55dfa4SMax Reitz# relative path, it will always be evaluated relative to qemu's CWD (but not
1006f55dfa4SMax Reitz# relative to the overlay!). While this is more or less intended, it is still
1016f55dfa4SMax Reitz# pretty strange and thus not something that is tested here.
1026f55dfa4SMax Reitz# (The root of the issue is the use of a relative path with a protocol prefix.
1036f55dfa4SMax Reitz#  This may always give you weird results because in one sense, qemu considers
1046f55dfa4SMax Reitz#  such paths absolute, whereas in another, they are still relative.)
1056f55dfa4SMax Reitz
1066f55dfa4SMax Reitz
1076f55dfa4SMax Reitz# success, all done
1086f55dfa4SMax Reitzecho '*** done'
1096f55dfa4SMax Reitzrm -f $seq.full
1106f55dfa4SMax Reitzstatus=0
111