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