4 # Test that a backing image is put back in read-only mode after
5 # block-commit (both when it fails and when it succeeds).
7 # Copyright (C) 2019 Igalia, S.L.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 owner
=berto@igalia.com
27 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
51 # Create the images: base <- int <- active
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
56 # Launch QEMU with these two drives:
57 # none0: base (read-only)
58 # none1: base <- int <- active
59 _launch_qemu
-drive if=none
,file="${TEST_IMG}.base",node-name
=base
,read-only
=on \
60 -drive if=none
,file="${TEST_IMG}",backing.node-name
=int
,backing.backing
=base
62 _send_qemu_cmd
$QEMU_HANDLE \
63 "{ 'execute': 'qmp_capabilities' }" \
67 echo '=== Send a write command to a drive opened in read-only mode (1)'
69 _send_qemu_cmd
$QEMU_HANDLE \
70 "{ 'execute': 'human-monitor-command',
71 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}" \
75 echo '=== Run block-commit on base using an invalid filter node name'
77 _send_qemu_cmd
$QEMU_HANDLE \
78 "{ 'execute': 'block-commit',
79 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int',
80 'filter-node-name': '1234'}}" \
84 echo '=== Send a write command to a drive opened in read-only mode (2)'
86 _send_qemu_cmd
$QEMU_HANDLE \
87 "{ 'execute': 'human-monitor-command',
88 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}" \
92 echo '=== Run block-commit on base using the default filter node name'
94 _send_qemu_cmd
$QEMU_HANDLE \
95 "{ 'execute': 'block-commit',
96 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int'}}" \
99 # Wait for block-commit to finish
100 _send_qemu_cmd
$QEMU_HANDLE '' \
104 echo '=== Send a write command to a drive opened in read-only mode (3)'
106 _send_qemu_cmd
$QEMU_HANDLE \
107 "{ 'execute': 'human-monitor-command',
108 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}" \