1f4e732a0SMax Reitz#!/bin/bash 2f4e732a0SMax Reitz# 3f4e732a0SMax Reitz# Test that qemu-img convert -S 0 fully allocates the target image 4f4e732a0SMax Reitz# 5f4e732a0SMax Reitz# Copyright (C) 2016 Red Hat, Inc. 6f4e732a0SMax Reitz# 7f4e732a0SMax Reitz# This program is free software; you can redistribute it and/or modify 8f4e732a0SMax Reitz# it under the terms of the GNU General Public License as published by 9f4e732a0SMax Reitz# the Free Software Foundation; either version 2 of the License, or 10f4e732a0SMax Reitz# (at your option) any later version. 11f4e732a0SMax Reitz# 12f4e732a0SMax Reitz# This program is distributed in the hope that it will be useful, 13f4e732a0SMax Reitz# but WITHOUT ANY WARRANTY; without even the implied warranty of 14f4e732a0SMax Reitz# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15f4e732a0SMax Reitz# GNU General Public License for more details. 16f4e732a0SMax Reitz# 17f4e732a0SMax Reitz# You should have received a copy of the GNU General Public License 18f4e732a0SMax Reitz# along with this program. If not, see <http://www.gnu.org/licenses/>. 19f4e732a0SMax Reitz# 20f4e732a0SMax Reitz 21f4e732a0SMax Reitz# creator 22f4e732a0SMax Reitzowner=mreitz@redhat.com 23f4e732a0SMax Reitz 24f4e732a0SMax Reitzseq="$(basename $0)" 25f4e732a0SMax Reitzecho "QA output created by $seq" 26f4e732a0SMax Reitz 27f4e732a0SMax Reitzhere="$PWD" 28f4e732a0SMax Reitztmp=/tmp/$$ 29f4e732a0SMax Reitzstatus=1 # failure is the default! 30f4e732a0SMax Reitz 31f4e732a0SMax Reitz_cleanup() 32f4e732a0SMax Reitz{ 33f4e732a0SMax Reitz _cleanup_test_img 34f4e732a0SMax Reitz} 35f4e732a0SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 36f4e732a0SMax Reitz 37f4e732a0SMax Reitz# get standard environment, filters and checks 38f4e732a0SMax Reitz. ./common.rc 39f4e732a0SMax Reitz. ./common.filter 40f4e732a0SMax Reitz 41*1fd06db0SMax Reitz_supported_fmt raw qcow2 42f4e732a0SMax Reitz_supported_proto file 43f4e732a0SMax Reitz_supported_os Linux 44f4e732a0SMax Reitz 45f4e732a0SMax Reitz 46f4e732a0SMax Reitzimg_size=1048576 47f4e732a0SMax Reitz 48f4e732a0SMax Reitz 49f4e732a0SMax Reitzecho 50*1fd06db0SMax Reitzecho '=== Mapping sparse conversion ===' 51f4e732a0SMax Reitzecho 52f4e732a0SMax Reitz 53f4e732a0SMax Reitz$QEMU_IMG_PROG convert -O "$IMGFMT" -S 512 \ 54f4e732a0SMax Reitz "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \ 55f4e732a0SMax Reitz "$TEST_IMG" 56f4e732a0SMax Reitz 57*1fd06db0SMax Reitz$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map 58f4e732a0SMax Reitz 59f4e732a0SMax Reitz 60f4e732a0SMax Reitzecho 61*1fd06db0SMax Reitzecho '=== Mapping non-sparse conversion ===' 62f4e732a0SMax Reitzecho 63f4e732a0SMax Reitz 64f4e732a0SMax Reitz$QEMU_IMG convert -O "$IMGFMT" -S 0 \ 65f4e732a0SMax Reitz "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \ 66f4e732a0SMax Reitz "$TEST_IMG" 67f4e732a0SMax Reitz 68*1fd06db0SMax Reitz$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map 69f4e732a0SMax Reitz 70f4e732a0SMax Reitz 71f4e732a0SMax Reitz# success, all done 72f4e732a0SMax Reitzecho "*** done" 73f4e732a0SMax Reitzrm -f $seq.full 74f4e732a0SMax Reitzstatus=0 75