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