4 # Test reopening a backing image after block-stream and block-commit
6 # Copyright (C) 2018 Igalia, S.L.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 owner=berto@igalia.com
26 echo "QA output created by $seq"
29 status=1 # failure is the default!
34 _rm_test_img "$TEST_IMG.base"
35 _rm_test_img "$TEST_IMG.int"
37 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
44 # Any format implementing BlockDriver.bdrv_change_backing_file
45 _supported_fmt qcow2 qed
46 _supported_proto file fuse
52 TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE
53 TEST_IMG="$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" -F $IMGFMT
54 _make_test_img -b "$TEST_IMG.int" -F $IMGFMT -F $IMGFMT
56 # First test: reopen $TEST.IMG changing the detect-zeroes option on
57 # its backing file ($TEST_IMG.int).
59 echo "*** Change an option on the backing file"
61 _launch_qemu -drive if=none,file="${TEST_IMG}"
62 _send_qemu_cmd $QEMU_HANDLE \
63 "{ 'execute': 'qmp_capabilities' }" \
66 _send_qemu_cmd $QEMU_HANDLE \
67 "{ 'execute': 'human-monitor-command',
68 'arguments': { 'command-line':
69 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \
74 # Second test: stream $TEST_IMG.base into $TEST_IMG.int and then
75 # reopen $TEST.IMG changing the detect-zeroes option on its new
76 # backing file ($TEST_IMG.base).
78 echo "*** Stream and then change an option on the backing file"
80 _launch_qemu -drive if=none,file="${TEST_IMG}"
81 _send_qemu_cmd $QEMU_HANDLE \
82 "{ 'execute': 'qmp_capabilities' }" \
85 _send_qemu_cmd $QEMU_HANDLE \
86 "{ 'execute': 'block-stream', \
87 'arguments': { 'device': 'none0',
88 'base': '${TEST_IMG}.base' } }" \
91 # Wait for block-stream to finish
94 _send_qemu_cmd $QEMU_HANDLE \
95 "{ 'execute': 'human-monitor-command',
96 'arguments': { 'command-line':
97 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \
102 # Third test: commit $TEST_IMG.int into $TEST_IMG.base and then reopen
103 # $TEST.IMG changing the detect-zeroes option on its new backing file
106 echo "*** Commit and then change an option on the backing file"
108 # Create the images again
109 TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE
110 TEST_IMG="$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" -F $IMGFMT
111 _make_test_img -b "$TEST_IMG.int" -F $IMGFMT
113 _launch_qemu -drive if=none,file="${TEST_IMG}"
114 _send_qemu_cmd $QEMU_HANDLE \
115 "{ 'execute': 'qmp_capabilities' }" \
118 _send_qemu_cmd $QEMU_HANDLE \
119 "{ 'execute': 'block-commit', \
120 'arguments': { 'device': 'none0',
121 'top': '${TEST_IMG}.int' } }" \
124 # Wait for block-commit to finish
127 _send_qemu_cmd $QEMU_HANDLE \
128 "{ 'execute': 'human-monitor-command',
129 'arguments': { 'command-line':
130 'qemu-io none0 \"reopen -o backing.detect-zeroes=on\"' } }" \