1344acbd6SEric Blake#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: backing quick 3344acbd6SEric Blake# 4344acbd6SEric Blake# Test qcow backing file warnings 5344acbd6SEric Blake# 6*497a30dbSEric Blake# Copyright (C) 2020-2021 Red Hat, Inc. 7344acbd6SEric Blake# 8344acbd6SEric Blake# This program is free software; you can redistribute it and/or modify 9344acbd6SEric Blake# it under the terms of the GNU General Public License as published by 10344acbd6SEric Blake# the Free Software Foundation; either version 2 of the License, or 11344acbd6SEric Blake# (at your option) any later version. 12344acbd6SEric Blake# 13344acbd6SEric Blake# This program is distributed in the hope that it will be useful, 14344acbd6SEric Blake# but WITHOUT ANY WARRANTY; without even the implied warranty of 15344acbd6SEric Blake# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16344acbd6SEric Blake# GNU General Public License for more details. 17344acbd6SEric Blake# 18344acbd6SEric Blake# You should have received a copy of the GNU General Public License 19344acbd6SEric Blake# along with this program. If not, see <http://www.gnu.org/licenses/>. 20344acbd6SEric Blake# 21344acbd6SEric Blake 22344acbd6SEric Blakeseq=`basename $0` 23344acbd6SEric Blakeecho "QA output created by $seq" 24344acbd6SEric Blake 25344acbd6SEric Blakestatus=1 # failure is the default! 26344acbd6SEric Blake 27344acbd6SEric Blake_cleanup() 28344acbd6SEric Blake{ 29344acbd6SEric Blake _cleanup_test_img 30344acbd6SEric Blake _rm_test_img "$TEST_IMG.qcow2" 31344acbd6SEric Blake} 32344acbd6SEric Blaketrap "_cleanup; exit \$status" 0 1 2 3 15 33344acbd6SEric Blake 34344acbd6SEric Blake# get standard environment, filters and checks 35344acbd6SEric Blake. ./common.rc 36344acbd6SEric Blake. ./common.filter 37344acbd6SEric Blake 38344acbd6SEric Blake_supported_fmt qcow 39344acbd6SEric Blake_supported_proto file 40344acbd6SEric Blake_supported_os Linux 41344acbd6SEric Blake 42344acbd6SEric Blakesize=32M 43344acbd6SEric Blake 44344acbd6SEric Blakeecho 45344acbd6SEric Blakeecho "== qcow backed by qcow ==" 46344acbd6SEric Blake 47344acbd6SEric BlakeTEST_IMG="$TEST_IMG.base" _make_test_img $size 48344acbd6SEric Blake_make_test_img -b "$TEST_IMG.base" $size 49344acbd6SEric Blake_make_test_img -b "$TEST_IMG.base" -F $IMGFMT $size 50344acbd6SEric Blake_img_info 51344acbd6SEric Blake 52344acbd6SEric Blakeecho 53344acbd6SEric Blakeecho "== mismatched command line detection ==" 54344acbd6SEric Blake 55344acbd6SEric Blake_make_test_img -b "$TEST_IMG.base" -F vmdk 56344acbd6SEric Blake_make_test_img -b "$TEST_IMG.base" -F vmdk $size 57344acbd6SEric Blakeecho 58344acbd6SEric Blake# Use of -u bypasses the backing format sanity check 59344acbd6SEric Blake_make_test_img -u -b "$TEST_IMG.base" -F vmdk 60344acbd6SEric Blake_make_test_img -u -b "$TEST_IMG.base" -F vmdk $size 61344acbd6SEric Blakeecho 62344acbd6SEric Blake# But the format must still be recognized 63344acbd6SEric Blake_make_test_img -b "$TEST_IMG.base" -F garbage $size 64344acbd6SEric Blake_make_test_img -u -b "$TEST_IMG.base" -F garbage $size 65344acbd6SEric Blake_img_info 66344acbd6SEric Blake 67344acbd6SEric Blakeecho 68344acbd6SEric Blakeecho "== qcow backed by raw ==" 69344acbd6SEric Blake 70344acbd6SEric Blakerm "$TEST_IMG.base" 71344acbd6SEric Blaketruncate --size=$size "$TEST_IMG.base" 72344acbd6SEric Blake_make_test_img -b "$TEST_IMG.base" $size 73344acbd6SEric Blake_make_test_img -b "$TEST_IMG.base" -F raw $size 74344acbd6SEric Blake_img_info 75344acbd6SEric Blake 76344acbd6SEric Blakeecho 77344acbd6SEric Blakeecho "== commit cannot change type of raw backing file ==" 78344acbd6SEric BlakeTEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 _make_test_img $size 79344acbd6SEric Blaketruncate --size=$size "$TEST_IMG.qcow2" 80344acbd6SEric Blake$QEMU_IMG convert -n -f raw -O $IMGFMT "$TEST_IMG.qcow2" "$TEST_IMG" 81344acbd6SEric Blake$QEMU_IMG commit -f $IMGFMT "$TEST_IMG" && echo "unexpected success" 82344acbd6SEric BlakeTEST_IMG="$TEST_IMG.base" _img_info 83344acbd6SEric Blake 84344acbd6SEric Blake# success, all done 85344acbd6SEric Blakeecho "*** done" 86344acbd6SEric Blakerm -f $seq.full 87344acbd6SEric Blakestatus=0 88