1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Reitzstatus=1 # failure is the default! 28f4e732a0SMax Reitz 29f4e732a0SMax Reitz_cleanup() 30f4e732a0SMax Reitz{ 31f4e732a0SMax Reitz _cleanup_test_img 32f4e732a0SMax Reitz} 33f4e732a0SMax Reitztrap "_cleanup; exit \$status" 0 1 2 3 15 34f4e732a0SMax Reitz 35f4e732a0SMax Reitz# get standard environment, filters and checks 36f4e732a0SMax Reitz. ./common.rc 37f4e732a0SMax Reitz. ./common.filter 38f4e732a0SMax Reitz 391fd06db0SMax Reitz_supported_fmt raw qcow2 40f4e732a0SMax Reitz_supported_proto file 41f4e732a0SMax Reitz_supported_os Linux 42f4e732a0SMax Reitz 43f4e732a0SMax Reitz 44f4e732a0SMax Reitzimg_size=1048576 45f4e732a0SMax Reitz 46f4e732a0SMax Reitz 47f4e732a0SMax Reitzecho 481fd06db0SMax Reitzecho '=== Mapping sparse conversion ===' 49f4e732a0SMax Reitzecho 50f4e732a0SMax Reitz 51f4e732a0SMax Reitz$QEMU_IMG_PROG convert -O "$IMGFMT" -S 512 \ 52f4e732a0SMax Reitz "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \ 53f4e732a0SMax Reitz "$TEST_IMG" 54f4e732a0SMax Reitz 551fd06db0SMax Reitz$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map 56f4e732a0SMax Reitz 57f4e732a0SMax Reitz 58f4e732a0SMax Reitzecho 591fd06db0SMax Reitzecho '=== Mapping non-sparse conversion ===' 60f4e732a0SMax Reitzecho 61f4e732a0SMax Reitz 62f4e732a0SMax Reitz$QEMU_IMG convert -O "$IMGFMT" -S 0 \ 63f4e732a0SMax Reitz "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \ 64f4e732a0SMax Reitz "$TEST_IMG" 65f4e732a0SMax Reitz 661fd06db0SMax Reitz$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map 67f4e732a0SMax Reitz 68f4e732a0SMax Reitz 69f4e732a0SMax Reitz# success, all done 70f4e732a0SMax Reitzecho "*** done" 71f4e732a0SMax Reitzrm -f $seq.full 72f4e732a0SMax Reitzstatus=0 73