xref: /openbmc/qemu/tests/qemu-iotests/284 (revision cff61408)
1087ab8e7SDaniel P. Berrangé#!/usr/bin/env bash
29dd003a9SVladimir Sementsov-Ogievskiy# group: rw
3087ab8e7SDaniel P. Berrangé#
4087ab8e7SDaniel P. Berrangé# Test ref count checks on encrypted images
5087ab8e7SDaniel P. Berrangé#
6087ab8e7SDaniel P. Berrangé# Copyright (C) 2019 Red Hat, Inc.
7087ab8e7SDaniel P. Berrangé#
8087ab8e7SDaniel P. Berrangé# This program is free software; you can redistribute it and/or modify
9087ab8e7SDaniel P. Berrangé# it under the terms of the GNU General Public License as published by
10087ab8e7SDaniel P. Berrangé# the Free Software Foundation; either version 2 of the License, or
11087ab8e7SDaniel P. Berrangé# (at your option) any later version.
12087ab8e7SDaniel P. Berrangé#
13087ab8e7SDaniel P. Berrangé# This program is distributed in the hope that it will be useful,
14087ab8e7SDaniel P. Berrangé# but WITHOUT ANY WARRANTY; without even the implied warranty of
15087ab8e7SDaniel P. Berrangé# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16087ab8e7SDaniel P. Berrangé# GNU General Public License for more details.
17087ab8e7SDaniel P. Berrangé#
18087ab8e7SDaniel P. Berrangé# You should have received a copy of the GNU General Public License
19087ab8e7SDaniel P. Berrangé# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20087ab8e7SDaniel P. Berrangé#
21087ab8e7SDaniel P. Berrangé
22087ab8e7SDaniel P. Berrangé# creator
23087ab8e7SDaniel P. Berrangéowner=berrange@redhat.com
24087ab8e7SDaniel P. Berrangé
25087ab8e7SDaniel P. Berrangéseq=`basename $0`
26087ab8e7SDaniel P. Berrangéecho "QA output created by $seq"
27087ab8e7SDaniel P. Berrangé
28087ab8e7SDaniel P. Berrangéstatus=1        # failure is the default!
29087ab8e7SDaniel P. Berrangé
30087ab8e7SDaniel P. Berrangé_cleanup()
31087ab8e7SDaniel P. Berrangé{
32087ab8e7SDaniel P. Berrangé        _cleanup_test_img
33087ab8e7SDaniel P. Berrangé}
34087ab8e7SDaniel P. Berrangétrap "_cleanup; exit \$status" 0 1 2 3 15
35087ab8e7SDaniel P. Berrangé
36*cff61408SThomas HuthIMGOPTSSYNTAX=true
37*cff61408SThomas Huth
38087ab8e7SDaniel P. Berrangé# get standard environment, filters and checks
39087ab8e7SDaniel P. Berrangé. ./common.rc
40087ab8e7SDaniel P. Berrangé. ./common.filter
41087ab8e7SDaniel P. Berrangé
42087ab8e7SDaniel P. Berrangé_supported_fmt qcow2
43087ab8e7SDaniel P. Berrangé_supported_proto generic
44087ab8e7SDaniel P. Berrangé_supported_os Linux
45d2a839edSMax Reitz_require_working_luks
46087ab8e7SDaniel P. Berrangé
47087ab8e7SDaniel P. Berrangé
48087ab8e7SDaniel P. Berrangésize=1M
49087ab8e7SDaniel P. Berrangé
50087ab8e7SDaniel P. BerrangéSECRET="secret,id=sec0,data=astrochicken"
51087ab8e7SDaniel P. Berrangé
52087ab8e7SDaniel P. BerrangéQEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
53087ab8e7SDaniel P. Berrangé
54087ab8e7SDaniel P. Berrangé_run_test()
55087ab8e7SDaniel P. Berrangé{
56087ab8e7SDaniel P. Berrangé        OLD_TEST_IMG="$TEST_IMG"
57*cff61408SThomas Huth        TEST_IMG="$TEST_IMG,encrypt.key-secret=sec0"
58087ab8e7SDaniel P. Berrangé        QEMU_IMG_EXTRA_ARGS="--image-opts --object $SECRET"
59087ab8e7SDaniel P. Berrangé
60087ab8e7SDaniel P. Berrangé        echo
61087ab8e7SDaniel P. Berrangé        echo "== cluster size $csize"
62087ab8e7SDaniel P. Berrangé        echo "== checking image refcounts =="
63087ab8e7SDaniel P. Berrangé        _check_test_img
64087ab8e7SDaniel P. Berrangé
65087ab8e7SDaniel P. Berrangé        echo
66087ab8e7SDaniel P. Berrangé        echo "== writing some data =="
67087ab8e7SDaniel P. Berrangé        $QEMU_IO -c "write -P 0x9 0 1"  $QEMU_IMG_EXTRA_ARGS $TEST_IMG | _filter_qemu_io | _filter_testdir
68087ab8e7SDaniel P. Berrangé        echo
69087ab8e7SDaniel P. Berrangé        echo "== rechecking image refcounts =="
70087ab8e7SDaniel P. Berrangé        _check_test_img
71087ab8e7SDaniel P. Berrangé
72087ab8e7SDaniel P. Berrangé        echo
73087ab8e7SDaniel P. Berrangé        echo "== writing some more data =="
74087ab8e7SDaniel P. Berrangé        $QEMU_IO -c "write -P 0x9 $csize 1" $QEMU_IMG_EXTRA_ARGS $TEST_IMG | _filter_qemu_io | _filter_testdir
75087ab8e7SDaniel P. Berrangé        echo
76087ab8e7SDaniel P. Berrangé        echo "== rechecking image refcounts =="
77087ab8e7SDaniel P. Berrangé        _check_test_img
78087ab8e7SDaniel P. Berrangé
79087ab8e7SDaniel P. Berrangé        TEST_IMG="$OLD_TEST_IMG"
80087ab8e7SDaniel P. Berrangé        QEMU_IMG_EXTRA_ARGS=
81087ab8e7SDaniel P. Berrangé}
82087ab8e7SDaniel P. Berrangé
83087ab8e7SDaniel P. Berrangé
84087ab8e7SDaniel P. Berrangéecho
85087ab8e7SDaniel P. Berrangéecho "testing LUKS qcow2 encryption"
86087ab8e7SDaniel P. Berrangéecho
87087ab8e7SDaniel P. Berrangé
88087ab8e7SDaniel P. Berrangéfor csize in 512 2048 32768
89087ab8e7SDaniel P. Berrangédo
90087ab8e7SDaniel P. Berrangé  _make_test_img --object $SECRET -o "encrypt.format=luks,encrypt.key-secret=sec0,encrypt.iter-time=10,cluster_size=$csize" $size
91087ab8e7SDaniel P. Berrangé  _run_test
92087ab8e7SDaniel P. Berrangé  _cleanup_test_img
93087ab8e7SDaniel P. Berrangédone
94087ab8e7SDaniel P. Berrangé
95087ab8e7SDaniel P. Berrangé# success, all done
96087ab8e7SDaniel P. Berrangéecho "*** done"
97087ab8e7SDaniel P. Berrangérm -f $seq.full
98087ab8e7SDaniel P. Berrangéstatus=0
99