xref: /openbmc/qemu/tests/qemu-iotests/130 (revision 11a82d14)
1*11a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env 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 Wolfstatus=1	# failure is the default!
30e4603fe1SKevin Wolf
31e4603fe1SKevin Wolf_cleanup()
32e4603fe1SKevin Wolf{
33ecfa1854SJeff Cody    _cleanup_qemu
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
45a98f49f4SJeff Cody_unsupported_proto vxhs
46e4603fe1SKevin Wolf_supported_os Linux
4794254c9bSMax Reitz# We are going to use lazy-refcounts
4894254c9bSMax Reitz_unsupported_imgopts 'compat=0.10'
49e4603fe1SKevin Wolf
50e4603fe1SKevin Wolfqemu_comm_method="monitor"
51e4603fe1SKevin Wolf
52e4603fe1SKevin Wolf
53e4603fe1SKevin WolfTEST_IMG="$TEST_IMG.orig" _make_test_img 64M
54e4603fe1SKevin WolfTEST_IMG="$TEST_IMG.base" _make_test_img 64M
55e4603fe1SKevin Wolf_make_test_img 64M
56e4603fe1SKevin Wolf_img_info | _filter_img_info
57e4603fe1SKevin Wolf
58e4603fe1SKevin Wolfecho
59e4603fe1SKevin Wolfecho "=== HMP commit ==="
60e4603fe1SKevin Wolfecho
61e4603fe1SKevin Wolf# bdrv_make_empty() involves a header update for qcow2
62e4603fe1SKevin Wolf
63e4603fe1SKevin Wolf# Test that a backing file isn't written
64137a905fSBo Tu_launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base"
65137a905fSBo Tu_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)"
66e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE '' '(qemu)'
67e4603fe1SKevin Wolf_cleanup_qemu
68e4603fe1SKevin Wolf_img_info | _filter_img_info
69e4603fe1SKevin Wolf
70e4603fe1SKevin Wolf# Make sure that if there was a backing file that was just overridden on the
71e4603fe1SKevin Wolf# command line, that backing file is retained, with the right format
72e4603fe1SKevin Wolf_make_test_img -F raw -b "$TEST_IMG.orig" 64M
73137a905fSBo Tu_launch_qemu -drive id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT
74137a905fSBo Tu_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)"
75e4603fe1SKevin Wolf_send_qemu_cmd $QEMU_HANDLE '' '(qemu)'
76e4603fe1SKevin Wolf_cleanup_qemu
77e4603fe1SKevin Wolf_img_info | _filter_img_info
78e4603fe1SKevin Wolf
79e4603fe1SKevin Wolfecho
80e4603fe1SKevin Wolfecho "=== Marking image dirty (lazy refcounts) ==="
81e4603fe1SKevin Wolfecho
82e4603fe1SKevin Wolf
83e4603fe1SKevin Wolf# Test that a backing file isn't written
84e4603fe1SKevin Wolf_make_test_img 64M
85e4603fe1SKevin Wolf$QEMU_IO -c "open -o backing.file.filename=$TEST_IMG.base,lazy-refcounts=on $TEST_IMG" -c "write 0 4k" | _filter_qemu_io
86e4603fe1SKevin Wolf_img_info | _filter_img_info
87e4603fe1SKevin Wolf
88e4603fe1SKevin Wolf# Make sure that if there was a backing file that was just overridden on the
89e4603fe1SKevin Wolf# command line, that backing file is retained, with the right format
90e4603fe1SKevin Wolf_make_test_img -F raw -b "$TEST_IMG.orig" 64M
91e4603fe1SKevin 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
92e4603fe1SKevin Wolf_img_info | _filter_img_info
93e4603fe1SKevin Wolf
94e4603fe1SKevin Wolf# success, all done
95e4603fe1SKevin Wolfecho '*** done'
96e4603fe1SKevin Wolfrm -f $seq.full
97e4603fe1SKevin Wolfstatus=0
98