4 # Test commit block job where top has two parents
6 # Copyright (C) 2017 Red Hat, Inc.
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=kwolf@redhat.com
26 echo "QA output created by $seq"
28 status=1 # failure is the default!
32 _rm_test_img "${TEST_IMG}.mid"
33 _rm_test_img "${TEST_IMG}.ovl2"
34 _rm_test_img "${TEST_IMG}.ovl3"
38 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
46 _supported_proto file fuse
47 # An external data file would change the query-named-block-nodes output
48 _unsupported_imgopts data_file
53 echo === Preparing and starting VM ===
56 TEST_IMG="${TEST_IMG}.base" _make_test_img $size
57 TEST_IMG="${TEST_IMG}.mid" _make_test_img -o "backing_fmt=$IMGFMT" -b "${TEST_IMG}.base"
58 _make_test_img -b "${TEST_IMG}.mid" -F $IMGFMT
59 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" -F $IMGFMT
61 $QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io
63 qemu_comm_method="qmp"
67 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.base,node-name=base" \
68 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.mid,node-name=mid,backing=base" \
69 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG},node-name=top,backing=mid" \
70 -blockdev "driver=${IMGFMT},file.driver=file,file.filename=${TEST_IMG}.ovl2,node-name=top2,backing=mid"
72 _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}'
75 echo === Perform commit job ===
79 "{ 'execute': 'block-commit',
80 'arguments': { 'job-id': 'commit0',
82 'base':'$TEST_IMG.base',
83 'top': '$TEST_IMG.mid' } }" \
85 _send_qemu_cmd $h "" "^}"
88 echo === Check that both top and top2 point to base now ===
91 _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" |
92 _filter_generated_node_ids | _filter_actual_image_size | _filter_img_info
94 _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}"
98 TEST_IMG="$TEST_IMG.ovl2" _img_info
102 echo === Preparing and starting VM with -drive ===
105 TEST_IMG="${TEST_IMG}.base" _make_test_img $size
106 TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" -F $IMGFMT
107 _make_test_img -b "${TEST_IMG}.mid" -F $IMGFMT
108 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" -F $IMGFMT
109 TEST_IMG="${TEST_IMG}.ovl3" _make_test_img -b "${TEST_IMG}.ovl2" -F $IMGFMT
111 $QEMU_IO -c 'write -P 0x55 1M 64k' "${TEST_IMG}.mid" | _filter_qemu_io
113 qemu_comm_method="qmp"
117 -drive "driver=${IMGFMT},file=${TEST_IMG},node-name=top,backing.node-name=mid" \
118 -drive "driver=${IMGFMT},file=${TEST_IMG}.ovl3,node-name=top2,backing.backing=mid"
120 _send_qemu_cmd $h "{ 'execute': 'qmp_capabilities' }" '^}'
123 echo === Perform commit job ===
127 "{ 'execute': 'block-commit',
128 'arguments': { 'job-id': 'commit0',
130 'base':'$TEST_IMG.base',
131 'top': '$TEST_IMG.mid' } }" \
133 _send_qemu_cmd $h "" "^}"
136 echo === Check that both top and top2 point to base now ===
139 _send_qemu_cmd $h "{ 'execute': 'query-named-block-nodes' }" "^}" |
140 _filter_generated_node_ids | _filter_actual_image_size | _filter_img_info
142 _send_qemu_cmd $h "{ 'execute': 'quit' }" "^}"
146 TEST_IMG="$TEST_IMG.ovl2" _img_info