3 # Test that a backing image is put back in read-only mode after
4 # block-commit (both when it fails and when it succeeds).
6 # Copyright (C) 2019 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"
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
50 # Create the images: base <- int <- active
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 # Launch QEMU with these two drives:
56 # none0: base (read-only)
57 # none1: base <- int <- active
58 _launch_qemu
-drive if=none
,file="${TEST_IMG}.base",node-name
=base
,read-only
=on \
59 -drive if=none
,file="${TEST_IMG}",backing.node-name
=int
,backing.backing
=base
61 _send_qemu_cmd
$QEMU_HANDLE \
62 "{ 'execute': 'qmp_capabilities' }" \
66 echo '=== Send a write command to a drive opened in read-only mode (1)'
68 _send_qemu_cmd
$QEMU_HANDLE \
69 "{ 'execute': 'human-monitor-command',
70 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}" \
74 echo '=== Run block-commit on base using an invalid filter node name'
76 _send_qemu_cmd
$QEMU_HANDLE \
77 "{ 'execute': 'block-commit',
78 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int',
79 'filter-node-name': '1234'}}" \
83 echo '=== Send a write command to a drive opened in read-only mode (2)'
85 _send_qemu_cmd
$QEMU_HANDLE \
86 "{ 'execute': 'human-monitor-command',
87 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}" \
91 echo '=== Run block-commit on base using the default filter node name'
93 _send_qemu_cmd
$QEMU_HANDLE \
94 "{ 'execute': 'block-commit',
95 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int'}}" \
98 # Wait for block-commit to finish
99 _send_qemu_cmd
$QEMU_HANDLE '' \
103 echo '=== Send a write command to a drive opened in read-only mode (3)'
105 _send_qemu_cmd
$QEMU_HANDLE \
106 "{ 'execute': 'human-monitor-command',
107 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}" \