xref: /openbmc/qemu/tests/qemu-iotests/198 (revision 1cc6169b)
1f0603329SDaniel P. Berrange#!/bin/bash
2f0603329SDaniel P. Berrange#
3f0603329SDaniel P. Berrange# Test commit of encrypted qcow2 files
4f0603329SDaniel P. Berrange#
5f0603329SDaniel P. Berrange# Copyright (C) 2017 Red Hat, Inc.
6f0603329SDaniel P. Berrange#
7f0603329SDaniel P. Berrange# This program is free software; you can redistribute it and/or modify
8f0603329SDaniel P. Berrange# it under the terms of the GNU General Public License as published by
9f0603329SDaniel P. Berrange# the Free Software Foundation; either version 2 of the License, or
10f0603329SDaniel P. Berrange# (at your option) any later version.
11f0603329SDaniel P. Berrange#
12f0603329SDaniel P. Berrange# This program is distributed in the hope that it will be useful,
13f0603329SDaniel P. Berrange# but WITHOUT ANY WARRANTY; without even the implied warranty of
14f0603329SDaniel P. Berrange# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15f0603329SDaniel P. Berrange# GNU General Public License for more details.
16f0603329SDaniel P. Berrange#
17f0603329SDaniel P. Berrange# You should have received a copy of the GNU General Public License
18f0603329SDaniel P. Berrange# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19f0603329SDaniel P. Berrange#
20f0603329SDaniel P. Berrange
21f0603329SDaniel P. Berrange# creator
22f0603329SDaniel P. Berrangeowner=berrange@redhat.com
23f0603329SDaniel P. Berrange
24f0603329SDaniel P. Berrangeseq=`basename $0`
25f0603329SDaniel P. Berrangeecho "QA output created by $seq"
26f0603329SDaniel P. Berrange
27f0603329SDaniel P. Berrangehere=`pwd`
28f0603329SDaniel P. Berrangestatus=1	# failure is the default!
29f0603329SDaniel P. Berrange
30f0603329SDaniel P. Berrange_cleanup()
31f0603329SDaniel P. Berrange{
32f0603329SDaniel P. Berrange	_cleanup_test_img
33f0603329SDaniel P. Berrange}
34f0603329SDaniel P. Berrangetrap "_cleanup; exit \$status" 0 1 2 3 15
35f0603329SDaniel P. Berrange
36f0603329SDaniel P. Berrange# get standard environment, filters and checks
37f0603329SDaniel P. Berrange. ./common.rc
38f0603329SDaniel P. Berrange. ./common.filter
39f0603329SDaniel P. Berrange
40f0603329SDaniel P. Berrange_supported_fmt qcow2
41f0603329SDaniel P. Berrange_supported_proto generic
42f0603329SDaniel P. Berrange_supported_os Linux
43f0603329SDaniel P. Berrange
44f0603329SDaniel P. Berrange
45f0603329SDaniel P. Berrangesize=16M
46f0603329SDaniel P. BerrangeTEST_IMG_BASE=$TEST_IMG.base
47f0603329SDaniel P. BerrangeSECRET0="secret,id=sec0,data=astrochicken"
48f0603329SDaniel P. BerrangeSECRET1="secret,id=sec1,data=furby"
49f0603329SDaniel P. Berrange
50f0603329SDaniel P. BerrangeTEST_IMG_SAVE=$TEST_IMG
51f0603329SDaniel P. BerrangeTEST_IMG=$TEST_IMG_BASE
52f0603329SDaniel P. Berrangeecho "== create base =="
53f0603329SDaniel P. Berrange_make_test_img --object $SECRET0 -o "encrypt.format=luks,encrypt.key-secret=sec0,encrypt.iter-time=10" $size
54f0603329SDaniel P. BerrangeTEST_IMG=$TEST_IMG_SAVE
55f0603329SDaniel P. Berrange
56f0603329SDaniel P. BerrangeIMGSPECBASE="driver=$IMGFMT,file.filename=$TEST_IMG_BASE,encrypt.key-secret=sec0"
57f0603329SDaniel P. BerrangeIMGSPECLAYER="driver=$IMGFMT,file.filename=$TEST_IMG,encrypt.key-secret=sec1"
58f0603329SDaniel P. BerrangeIMGSPEC="$IMGSPECLAYER,backing.driver=$IMGFMT,backing.file.filename=$TEST_IMG_BASE,backing.encrypt.key-secret=sec0"
59f0603329SDaniel P. BerrangeQEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
60f0603329SDaniel P. Berrange
61f0603329SDaniel P. Berrangeecho
62f0603329SDaniel P. Berrangeecho "== writing whole image base =="
63f0603329SDaniel P. Berrange$QEMU_IO --object $SECRET0 -c "write -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir
64f0603329SDaniel P. Berrange
65f0603329SDaniel P. Berrangeecho "== create overlay =="
66f0603329SDaniel P. Berrange_make_test_img --object $SECRET1 -o "encrypt.format=luks,encrypt.key-secret=sec1,encrypt.iter-time=10" -u -b "$TEST_IMG_BASE" $size
67f0603329SDaniel P. Berrange
68f0603329SDaniel P. Berrangeecho
69f0603329SDaniel P. Berrangeecho "== writing whole image layer =="
70f0603329SDaniel P. Berrange$QEMU_IO --object $SECRET0 --object $SECRET1 -c "write -P 0x9 0 $size" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir
71f0603329SDaniel P. Berrange
72f0603329SDaniel P. Berrangeecho
73f0603329SDaniel P. Berrangeecho "== verify pattern base =="
74f0603329SDaniel P. Berrange$QEMU_IO --object $SECRET0 -c "read -P 0xa 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir
75f0603329SDaniel P. Berrange
76f0603329SDaniel P. Berrangeecho
77f0603329SDaniel P. Berrangeecho "== verify pattern layer =="
78f0603329SDaniel P. Berrange$QEMU_IO --object $SECRET0 --object $SECRET1 -c "read -P 0x9 0 $size" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir
79f0603329SDaniel P. Berrange
80f0603329SDaniel P. Berrangeecho
81f0603329SDaniel P. Berrangeecho "== committing layer into base =="
82f0603329SDaniel P. Berrange$QEMU_IMG commit --object $SECRET0 --object $SECRET1 --image-opts $IMGSPEC | _filter_testdir
83f0603329SDaniel P. Berrange
84f0603329SDaniel P. Berrangeecho
85f0603329SDaniel P. Berrangeecho "== verify pattern base =="
86f0603329SDaniel P. Berrange$QEMU_IO --object $SECRET0 -c "read -P 0x9 0 $size" --image-opts $IMGSPECBASE | _filter_qemu_io | _filter_testdir
87f0603329SDaniel P. Berrange
88f0603329SDaniel P. Berrangeecho
89f0603329SDaniel P. Berrangeecho "== verify pattern layer =="
90f0603329SDaniel P. Berrange$QEMU_IO --object $SECRET0 --object $SECRET1 -c "read -P 0x9 0 $size" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir
91f0603329SDaniel P. Berrange
92f0603329SDaniel P. Berrangeecho
93f0603329SDaniel P. Berrangeecho "== checking image base =="
94*1cc6169bSMax Reitz$QEMU_IMG info --image-opts $IMGSPECBASE | _filter_img_info --format-specific \
95*1cc6169bSMax Reitz    | sed -e "/^disk size:/ D"
96f0603329SDaniel P. Berrange
97f0603329SDaniel P. Berrangeecho
98f0603329SDaniel P. Berrangeecho "== checking image layer =="
99*1cc6169bSMax Reitz$QEMU_IMG info --image-opts $IMGSPECLAYER | _filter_img_info --format-specific \
100*1cc6169bSMax Reitz    | sed -e "/^disk size:/ D"
101f0603329SDaniel P. Berrange
102f0603329SDaniel P. Berrange
103f0603329SDaniel P. Berrange# success, all done
104f0603329SDaniel P. Berrangeecho "*** done"
105f0603329SDaniel P. Berrangerm -f $seq.full
106f0603329SDaniel P. Berrangestatus=0
107