111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 29dd003a9SVladimir Sementsov-Ogievskiy# group: rw auto quick 3bb9f8dd0SDaniel P. Berrange# 4bb9f8dd0SDaniel P. Berrange# Test encrypted read/write using backing files 5bb9f8dd0SDaniel P. Berrange# 6bb9f8dd0SDaniel P. Berrange# Copyright (C) 2015 Red Hat, Inc. 7bb9f8dd0SDaniel P. Berrange# 8bb9f8dd0SDaniel P. Berrange# This program is free software; you can redistribute it and/or modify 9bb9f8dd0SDaniel P. Berrange# it under the terms of the GNU General Public License as published by 10bb9f8dd0SDaniel P. Berrange# the Free Software Foundation; either version 2 of the License, or 11bb9f8dd0SDaniel P. Berrange# (at your option) any later version. 12bb9f8dd0SDaniel P. Berrange# 13bb9f8dd0SDaniel P. Berrange# This program is distributed in the hope that it will be useful, 14bb9f8dd0SDaniel P. Berrange# but WITHOUT ANY WARRANTY; without even the implied warranty of 15bb9f8dd0SDaniel P. Berrange# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16bb9f8dd0SDaniel P. Berrange# GNU General Public License for more details. 17bb9f8dd0SDaniel P. Berrange# 18bb9f8dd0SDaniel P. Berrange# You should have received a copy of the GNU General Public License 19bb9f8dd0SDaniel P. Berrange# along with this program. If not, see <http://www.gnu.org/licenses/>. 20bb9f8dd0SDaniel P. Berrange# 21bb9f8dd0SDaniel P. Berrange 22bb9f8dd0SDaniel P. Berrange# creator 23bb9f8dd0SDaniel P. Berrangeowner=berrange@redhat.com 24bb9f8dd0SDaniel P. Berrange 25bb9f8dd0SDaniel P. Berrangeseq=`basename $0` 26bb9f8dd0SDaniel P. Berrangeecho "QA output created by $seq" 27bb9f8dd0SDaniel P. Berrange 28bb9f8dd0SDaniel P. Berrangestatus=1 # failure is the default! 29bb9f8dd0SDaniel P. Berrange 30bb9f8dd0SDaniel P. Berrange_cleanup() 31bb9f8dd0SDaniel P. Berrange{ 32bb9f8dd0SDaniel P. Berrange _cleanup_test_img 33bb9f8dd0SDaniel P. Berrange} 34bb9f8dd0SDaniel P. Berrangetrap "_cleanup; exit \$status" 0 1 2 3 15 35bb9f8dd0SDaniel P. Berrange 36bb9f8dd0SDaniel P. Berrange# get standard environment, filters and checks 37bb9f8dd0SDaniel P. Berrange. ./common.rc 38bb9f8dd0SDaniel P. Berrange. ./common.filter 39bb9f8dd0SDaniel P. Berrange 4023f831c3SDaniel P. Berrange_supported_fmt qcow qcow2 41*9e395444SThomas Huth_supported_proto file 42bb9f8dd0SDaniel P. Berrange 43bb9f8dd0SDaniel P. Berrange 44bb9f8dd0SDaniel P. Berrangesize=128M 45bb9f8dd0SDaniel P. BerrangeTEST_IMG_BASE=$TEST_IMG.base 46b25b387fSDaniel P. BerrangeSECRET="secret,id=sec0,data=astrochicken" 47bb9f8dd0SDaniel P. Berrange 48bb9f8dd0SDaniel P. BerrangeTEST_IMG_SAVE=$TEST_IMG 49bb9f8dd0SDaniel P. BerrangeTEST_IMG=$TEST_IMG_BASE 50bb9f8dd0SDaniel P. Berrangeecho "== create base ==" 51b25b387fSDaniel P. Berrange_make_test_img --object $SECRET -o "encryption=on,encrypt.key-secret=sec0" $size 52bb9f8dd0SDaniel P. BerrangeTEST_IMG=$TEST_IMG_SAVE 53bb9f8dd0SDaniel P. Berrange 54b25b387fSDaniel P. BerrangeIMGSPECBASE="driver=$IMGFMT,file.filename=$TEST_IMG_BASE,encrypt.key-secret=sec0" 55b25b387fSDaniel P. BerrangeIMGSPEC="driver=$IMGFMT,file.filename=$TEST_IMG,backing.driver=$IMGFMT,backing.file.filename=$TEST_IMG_BASE,backing.encrypt.key-secret=sec0,encrypt.key-secret=sec0" 56b25b387fSDaniel P. BerrangeQEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT 57b25b387fSDaniel P. Berrange 58bb9f8dd0SDaniel P. Berrangeecho 59bb9f8dd0SDaniel P. Berrangeecho "== writing whole image ==" 60b25b387fSDaniel P. Berrange$QEMU_IO --object $SECRET -c "write -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir 61bb9f8dd0SDaniel P. Berrange 62bb9f8dd0SDaniel P. Berrangeecho 63bb9f8dd0SDaniel P. Berrangeecho "== verify pattern ==" 64b25b387fSDaniel P. Berrange$QEMU_IO --object $SECRET -c "read -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir 65bb9f8dd0SDaniel P. Berrange 66bb9f8dd0SDaniel P. Berrangeecho "== create overlay ==" 67b66ff2c2SEric Blake_make_test_img -u --object $SECRET -o "encryption=on,encrypt.key-secret=sec0" -b "$TEST_IMG_BASE" -F $IMGFMT $size 68bb9f8dd0SDaniel P. Berrange 69bb9f8dd0SDaniel P. Berrangeecho 70bb9f8dd0SDaniel P. Berrangeecho "== writing part of a cluster ==" 71b25b387fSDaniel P. Berrange$QEMU_IO --object $SECRET -c "write -P 0xe 0 1024" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir 72bb9f8dd0SDaniel P. Berrange 73bb9f8dd0SDaniel P. Berrangeecho 74bb9f8dd0SDaniel P. Berrangeecho "== verify pattern ==" 75b25b387fSDaniel P. Berrange$QEMU_IO --object $SECRET -c "read -P 0xe 0 1024" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir 76bb9f8dd0SDaniel P. Berrangeecho 77bb9f8dd0SDaniel P. Berrangeecho "== verify pattern ==" 78b25b387fSDaniel P. Berrange$QEMU_IO --object $SECRET -c "read -P 0xa 1024 64512" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir 79bb9f8dd0SDaniel P. Berrange 80bb9f8dd0SDaniel P. Berrange 81bb9f8dd0SDaniel P. Berrange# success, all done 82bb9f8dd0SDaniel P. Berrangeecho "*** done" 83bb9f8dd0SDaniel P. Berrangerm -f $seq.full 84bb9f8dd0SDaniel P. Berrangestatus=0 85