xref: /openbmc/qemu/tests/qemu-iotests/130 (revision ecfa1854)
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{
34*ecfa1854SJeff Cody    _cleanup_qemu
35e4603fe1SKevin Wolf    _cleanup_test_img
36e4603fe1SKevin Wolf}
37e4603fe1SKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15
38e4603fe1SKevin Wolf
39e4603fe1SKevin Wolf# get standard environment, filters and checks
40e4603fe1SKevin Wolf. ./common.rc
41e4603fe1SKevin Wolf. ./common.filter
42e4603fe1SKevin Wolf. ./common.qemu
43e4603fe1SKevin Wolf
44e4603fe1SKevin Wolf_supported_fmt qcow2
45e4603fe1SKevin Wolf_supported_proto generic
46a98f49f4SJeff Cody_unsupported_proto vxhs
47e4603fe1SKevin Wolf_supported_os Linux
48e4603fe1SKevin Wolf
49e4603fe1SKevin Wolfqemu_comm_method="monitor"
50e4603fe1SKevin Wolf
51e4603fe1SKevin Wolf
52e4603fe1SKevin WolfTEST_IMG="$TEST_IMG.orig" _make_test_img 64M
53e4603fe1SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M
54e4603fe1SKevin Wolf_make_test_img 64M
55e4603fe1SKevin Wolf_img_info | _filter_img_info
56e4603fe1SKevin Wolf
57e4603fe1SKevin Wolfecho
58e4603fe1SKevin Wolfecho "=== HMP commit ==="
59e4603fe1SKevin Wolfecho
60e4603fe1SKevin Wolf# bdrv_make_empty() involves a header update for qcow2
61e4603fe1SKevin Wolf
62e4603fe1SKevin Wolf# Test that a backing file isn't written
63137a905fSBo Tu_launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base"
64137a905fSBo Tu_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)"
65e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE '' '(qemu)'
66e4603fe1SKevin Wolf_cleanup_qemu
67e4603fe1SKevin Wolf_img_info | _filter_img_info
68e4603fe1SKevin Wolf
69e4603fe1SKevin Wolf# Make sure that if there was a backing file that was just overridden on the
70e4603fe1SKevin Wolf# command line, that backing file is retained, with the right format
71e4603fe1SKevin Wolf_make_test_img -F raw -b "$TEST_IMG.orig" 64M
72137a905fSBo Tu_launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT
73137a905fSBo Tu_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)"
74e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE '' '(qemu)'
75e4603fe1SKevin Wolf_cleanup_qemu
76e4603fe1SKevin Wolf_img_info | _filter_img_info
77e4603fe1SKevin Wolf
78e4603fe1SKevin Wolfecho
79e4603fe1SKevin Wolfecho "=== Marking image dirty (lazy refcounts) ==="
80e4603fe1SKevin Wolfecho
81e4603fe1SKevin Wolf
82e4603fe1SKevin Wolf# Test that a backing file isn't written
83e4603fe1SKevin Wolf_make_test_img 64M
84e4603fe1SKevin Wolf$QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io
85e4603fe1SKevin Wolf_img_info | _filter_img_info
86e4603fe1SKevin Wolf
87e4603fe1SKevin Wolf# Make sure that if there was a backing file that was just overridden on the
88e4603fe1SKevin Wolf# command line, that backing file is retained, with the right format
89e4603fe1SKevin Wolf_make_test_img -F raw -b "$TEST_IMG.orig" 64M
90e4603fe1SKevin 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
91e4603fe1SKevin Wolf_img_info | _filter_img_info
92e4603fe1SKevin Wolf
93e4603fe1SKevin Wolf# success, all done
94e4603fe1SKevin Wolfecho '*** done'
95e4603fe1SKevin Wolfrm -f $seq.full
96e4603fe1SKevin Wolfstatus=0
97