111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2*9dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick 385456e0dSMax Reitz# 485456e0dSMax Reitz# Test vmdk backing file correlation 585456e0dSMax Reitz# 685456e0dSMax Reitz# Copyright (C) 2018 Red Hat, Inc. 785456e0dSMax Reitz# 885456e0dSMax Reitz# This program is free software; you can redistribute it and/or modify 985456e0dSMax Reitz# it under the terms of the GNU General Public License as published by 1085456e0dSMax Reitz# the Free Software Foundation; either version 2 of the License, or 1185456e0dSMax Reitz# (at your option) any later version. 1285456e0dSMax Reitz# 1385456e0dSMax Reitz# This program is distributed in the hope that it will be useful, 1485456e0dSMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 1585456e0dSMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1685456e0dSMax Reitz# GNU General Public License for more details. 1785456e0dSMax Reitz# 1885456e0dSMax Reitz# You should have received a copy of the GNU General Public License 1985456e0dSMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 2085456e0dSMax Reitz# 2185456e0dSMax Reitz 2285456e0dSMax Reitz# creator 2385456e0dSMax Reitzowner=mreitz@redhat.com 2485456e0dSMax Reitz 2585456e0dSMax Reitzseq=$(basename $0) 2685456e0dSMax Reitzecho "QA output created by $seq" 2785456e0dSMax Reitz 2885456e0dSMax Reitzstatus=1 # failure is the default! 2985456e0dSMax Reitz 3085456e0dSMax Reitz_cleanup() 3185456e0dSMax Reitz{ 3285456e0dSMax Reitz _cleanup_test_img 33f91ecbd7SMax Reitz _rm_test_img "$TEST_IMG.not_base" 3485456e0dSMax Reitz} 3585456e0dSMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 3685456e0dSMax Reitz 3785456e0dSMax Reitz# get standard environment, filters and checks 3885456e0dSMax Reitz. ./common.rc 3985456e0dSMax Reitz. ./common.filter 4085456e0dSMax Reitz. ./common.qemu 4185456e0dSMax Reitz 4285456e0dSMax Reitz# This tests vmdk-specific low-level functionality 4385456e0dSMax Reitz_supported_fmt vmdk 4485456e0dSMax Reitz_supported_proto file 4585456e0dSMax Reitz_supported_os Linux 4685456e0dSMax Reitz_unsupported_imgopts "subformat=monolithicFlat" \ 4785456e0dSMax Reitz "subformat=twoGbMaxExtentFlat" \ 4885456e0dSMax Reitz "subformat=twoGbMaxExtentSparse" 4985456e0dSMax Reitz 5085456e0dSMax ReitzTEST_IMG="$TEST_IMG.base" _make_test_img 1M 5185456e0dSMax ReitzTEST_IMG="$TEST_IMG.not_base" _make_test_img 1M 52b66ff2c2SEric Blake_make_test_img -b "$TEST_IMG.base" -F $IMGFMT 5385456e0dSMax Reitz 5485456e0dSMax Reitzmake_opts() 5585456e0dSMax Reitz{ 5685456e0dSMax Reitz node_name=$1 5785456e0dSMax Reitz filename=$2 5885456e0dSMax Reitz backing=$3 5985456e0dSMax Reitz 6085456e0dSMax Reitz if [ -z "$backing" ]; then 6185456e0dSMax Reitz backing="null" 6285456e0dSMax Reitz else 6385456e0dSMax Reitz backing="'$backing'" 6485456e0dSMax Reitz fi 6585456e0dSMax Reitz 6685456e0dSMax Reitz echo "{ 'node-name': '$node_name', 6785456e0dSMax Reitz 'driver': 'vmdk', 6885456e0dSMax Reitz 'file': { 6985456e0dSMax Reitz 'driver': 'file', 7085456e0dSMax Reitz 'filename': '$filename' 7185456e0dSMax Reitz }, 7285456e0dSMax Reitz 'backing': $backing }" 7385456e0dSMax Reitz} 7485456e0dSMax Reitz 7585456e0dSMax Reitzoverlay_opts=$(make_opts overlay "$TEST_IMG" backing) 7685456e0dSMax Reitzbase_opts=$(make_opts backing "$TEST_IMG.base") 7785456e0dSMax Reitznot_base_opts=$(make_opts backing "$TEST_IMG.not_base") 7885456e0dSMax Reitz 7985456e0dSMax Reitznot_vmdk_opts="{ 'node-name': 'backing', 'driver': 'null-co' }" 8085456e0dSMax Reitz 8185456e0dSMax Reitzecho 8285456e0dSMax Reitzecho '=== Testing fitting VMDK backing image ===' 8385456e0dSMax Reitzecho 8485456e0dSMax Reitz 8585456e0dSMax Reitzqemu_comm_method=monitor \ 8685456e0dSMax Reitz _launch_qemu -blockdev "$base_opts" -blockdev "$overlay_opts" 8785456e0dSMax Reitz 8885456e0dSMax Reitz# Should not return an error 8985456e0dSMax Reitz_send_qemu_cmd $QEMU_HANDLE 'qemu-io overlay "read 0 512"' 'ops' 9085456e0dSMax Reitz 9185456e0dSMax Reitz_cleanup_qemu 9285456e0dSMax Reitz 9385456e0dSMax Reitz 9485456e0dSMax Reitzecho 9585456e0dSMax Reitzecho '=== Testing unrelated VMDK backing image ===' 9685456e0dSMax Reitzecho 9785456e0dSMax Reitz 9885456e0dSMax Reitzqemu_comm_method=monitor \ 9985456e0dSMax Reitz _launch_qemu -blockdev "$not_base_opts" -blockdev "$overlay_opts" 10085456e0dSMax Reitz 10185456e0dSMax Reitz# Should fail (gracefully) 10285456e0dSMax Reitz_send_qemu_cmd $QEMU_HANDLE 'qemu-io overlay "read 0 512"' 'failed' 10385456e0dSMax Reitz 10485456e0dSMax Reitz_cleanup_qemu 10585456e0dSMax Reitz 10685456e0dSMax Reitz 10785456e0dSMax Reitzecho 10885456e0dSMax Reitzecho '=== Testing non-VMDK backing image ===' 10985456e0dSMax Reitzecho 11085456e0dSMax Reitz 11185456e0dSMax Reitz# FIXME: This is the reason why we have to use two -blockdev 11285456e0dSMax Reitz# invocations. You can only fully override the backing file options 11385456e0dSMax Reitz# if you either specify a node reference (as done here) or the new 11485456e0dSMax Reitz# options contain file.filename (which in this case they do not). 11585456e0dSMax Reitz# In other cases, file.filename will be set to whatever the image 11685456e0dSMax Reitz# header of the overlay contains (which we do not want). I consider 11785456e0dSMax Reitz# this a FIXME because with -blockdev, you cannot specify "partial" 11885456e0dSMax Reitz# options, so setting file.filename but leaving the rest as specified 11985456e0dSMax Reitz# by the user does not make sense. 12085456e0dSMax Reitzqemu_comm_method=monitor \ 12185456e0dSMax Reitz _launch_qemu -blockdev "$not_vmdk_opts" -blockdev "$overlay_opts" 12285456e0dSMax Reitz 12385456e0dSMax Reitz# Should fail (gracefully) 12485456e0dSMax Reitz_send_qemu_cmd $QEMU_HANDLE 'qemu-io overlay "read 0 512"' 'failed' 12585456e0dSMax Reitz 12685456e0dSMax Reitz_cleanup_qemu 12785456e0dSMax Reitz 12885456e0dSMax Reitz 12985456e0dSMax Reitz# success, all done 13085456e0dSMax Reitzecho "*** done" 13185456e0dSMax Reitzrm -f $seq.full 13285456e0dSMax Reitzstatus=0 133