3 # Test reopening a backing image after block-stream and block-commit
5 # Copyright (C) 2018 Igalia, S.L.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 owner
=berto@igalia.com
25 echo "QA output created by $seq"
28 status
=1 # failure is the default!
33 rm -f "$TEST_IMG.base"
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
43 # Any format implementing BlockDriver.bdrv_change_backing_file
44 _supported_fmt qcow2 qed
51 TEST_IMG
="$TEST_IMG.base" _make_test_img
$IMG_SIZE | _filter_imgfmt
52 TEST_IMG
="$TEST_IMG.int" _make_test_img
-b "$TEST_IMG.base" | _filter_imgfmt
53 _make_test_img
-b "$TEST_IMG.int" | _filter_imgfmt
55 # First test: reopen $TEST.IMG changing the detect-zeroes option on
56 # its backing file ($TEST_IMG.int).
58 echo "*** Change an option on the backing file"
60 _launch_qemu
-drive if=none
,file="${TEST_IMG}"
61 _send_qemu_cmd
$QEMU_HANDLE \
62 "{ 'execute': 'qmp_capabilities' }" \
65 _send_qemu_cmd
$QEMU_HANDLE \
66 "{ 'execute': 'human-monitor-command',
67 'arguments': { 'command-line':
68 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \
73 # Second test: stream $TEST_IMG.base into $TEST_IMG.int and then
74 # reopen $TEST.IMG changing the detect-zeroes option on its new
75 # backing file ($TEST_IMG.base).
77 echo "*** Stream and then change an option on the backing file"
79 _launch_qemu
-drive if=none
,file="${TEST_IMG}"
80 _send_qemu_cmd
$QEMU_HANDLE \
81 "{ 'execute': 'qmp_capabilities' }" \
84 _send_qemu_cmd
$QEMU_HANDLE \
85 "{ 'execute': 'block-stream', \
86 'arguments': { 'device': 'none0',
87 'base': '${TEST_IMG}.base' } }" \
90 # Wait for block-stream to finish
93 _send_qemu_cmd
$QEMU_HANDLE \
94 "{ 'execute': 'human-monitor-command',
95 'arguments': { 'command-line':
96 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \
101 # Third test: commit $TEST_IMG.int into $TEST_IMG.base and then reopen
102 # $TEST.IMG changing the detect-zeroes option on its new backing file
105 echo "*** Commit and then change an option on the backing file"
107 # Create the images again
108 TEST_IMG
="$TEST_IMG.base" _make_test_img
$IMG_SIZE | _filter_imgfmt
109 TEST_IMG
="$TEST_IMG.int" _make_test_img
-b "$TEST_IMG.base" | _filter_imgfmt
110 _make_test_img
-b "$TEST_IMG.int" | _filter_imgfmt
112 _launch_qemu
-drive if=none
,file="${TEST_IMG}"
113 _send_qemu_cmd
$QEMU_HANDLE \
114 "{ 'execute': 'qmp_capabilities' }" \
117 _send_qemu_cmd
$QEMU_HANDLE \
118 "{ 'execute': 'block-commit', \
119 'arguments': { 'device': 'none0',
120 'top': '${TEST_IMG}.int' } }" \
123 # Wait for block-commit to finish
126 _send_qemu_cmd
$QEMU_HANDLE \
127 "{ 'execute': 'human-monitor-command',
128 'arguments': { 'command-line':
129 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \