xref: /openbmc/qemu/tests/qemu-iotests/130 (revision 786a4ea8)
1#!/bin/bash
2#
3# Test that temporary backing file overrides (on the command line or in
4# blockdev-add) don't replace the original path stored in the image during
5# header updates.
6#
7# Copyright (C) 2015 Red Hat, Inc.
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21#
22
23# creator
24owner=kwolf@redhat.com
25
26seq="$(basename $0)"
27echo "QA output created by $seq"
28
29here="$PWD"
30tmp=/tmp/$$
31status=1	# failure is the default!
32
33_cleanup()
34{
35    _cleanup_test_img
36}
37trap "_cleanup; exit \$status" 0 1 2 3 15
38
39# get standard environment, filters and checks
40. ./common.rc
41. ./common.filter
42. ./common.qemu
43
44_supported_fmt qcow2
45_supported_proto generic
46_supported_os Linux
47
48qemu_comm_method="monitor"
49
50
51TEST_IMG="$TEST_IMG.orig" _make_test_img 64M
52TEST_IMG="$TEST_IMG.base" _make_test_img 64M
53_make_test_img 64M
54_img_info | _filter_img_info
55
56echo
57echo "=== HMP commit ==="
58echo
59# bdrv_make_empty() involves a header update for qcow2
60
61# Test that a backing file isn't written
62_launch_qemu -drive file="$TEST_IMG",backing.file.filename="$TEST_IMG.base"
63_send_qemu_cmd $QEMU_HANDLE "commit ide0-hd0" "(qemu)"
64_send_qemu_cmd $QEMU_HANDLE '' '(qemu)'
65_cleanup_qemu
66_img_info | _filter_img_info
67
68# Make sure that if there was a backing file that was just overridden on the
69# command line, that backing file is retained, with the right format
70_make_test_img -F raw -b "$TEST_IMG.orig" 64M
71_launch_qemu -drive file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT
72_send_qemu_cmd $QEMU_HANDLE "commit ide0-hd0" "(qemu)"
73_send_qemu_cmd $QEMU_HANDLE '' '(qemu)'
74_cleanup_qemu
75_img_info | _filter_img_info
76
77echo
78echo "=== Marking image dirty (lazy refcounts) ==="
79echo
80
81# Test that a backing file isn't written
82_make_test_img 64M
83$QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io
84_img_info | _filter_img_info
85
86# Make sure that if there was a backing file that was just overridden on the
87# command line, that backing file is retained, with the right format
88_make_test_img -F raw -b "$TEST_IMG.orig" 64M
89$QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,backing.driver=$IMGFMT,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io
90_img_info | _filter_img_info
91
92# success, all done
93echo '*** done'
94rm -f $seq.full
95status=0
96