3 # Test case for ejecting BDSs with block jobs still running on them
5 # Copyright (C) 2016 Red Hat, Inc.
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
=mreitz@redhat.com
25 echo "QA output created by $seq"
28 status
=1 # failure is the default!
33 rm -f "$TEST_DIR/{b,m,o}.$IMGFMT"
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
42 # Needs backing file and backing format support
43 _supported_fmt qcow2 qed
50 _send_qemu_cmd
$QEMU_HANDLE \
51 "{'execute': 'blockdev-add',
57 'filename': '$TEST_IMG'
61 _send_qemu_cmd
$QEMU_HANDLE \
66 # We want this to return an error because the block job is still running
67 _send_qemu_cmd
$QEMU_HANDLE \
68 "{'execute': 'x-blockdev-del',
69 'arguments': {'node-name': 'drv0'}}" \
72 _send_qemu_cmd
$QEMU_HANDLE \
73 "{'execute': 'block-job-cancel',
74 'arguments': {'device': 'job0'}}" \
77 _send_qemu_cmd
$QEMU_HANDLE \
78 "{'execute': 'x-blockdev-del',
79 'arguments': {'node-name': 'drv0'}}" \
84 TEST_IMG
="$TEST_DIR/b.$IMGFMT" _make_test_img
1M
85 TEST_IMG
="$TEST_DIR/m.$IMGFMT" _make_test_img
-b "$TEST_DIR/b.$IMGFMT" 1M
86 _make_test_img
-b "$TEST_DIR/m.$IMGFMT" 1M
88 _launch_qemu
-nodefaults
90 _send_qemu_cmd
$QEMU_HANDLE \
91 "{'execute': 'qmp_capabilities'}" \
95 echo '=== Testing drive-backup ==='
98 # drive-backup will not send BLOCK_JOB_READY by itself, and cancelling the job
99 # will consequently result in BLOCK_JOB_CANCELLED being emitted.
102 "{'execute': 'drive-backup',
103 'arguments': {'job-id': 'job0',
105 'target': '$TEST_DIR/o.$IMGFMT',
109 'BLOCK_JOB_CANCELLED'
112 echo '=== Testing drive-mirror ==='
115 # drive-mirror will send BLOCK_JOB_READY basically immediately, and cancelling
116 # the job will consequently result in BLOCK_JOB_COMPLETED being emitted.
119 "{'execute': 'drive-mirror',
120 'arguments': {'job-id': 'job0',
122 'target': '$TEST_DIR/o.$IMGFMT',
126 'BLOCK_JOB_COMPLETED'
129 echo '=== Testing active block-commit ==='
132 # An active block-commit will send BLOCK_JOB_READY basically immediately, and
133 # cancelling the job will consequently result in BLOCK_JOB_COMPLETED being
137 "{'execute': 'block-commit',
138 'arguments': {'job-id': 'job0', 'device': 'drv0'}}" \
140 'BLOCK_JOB_COMPLETED'
143 echo '=== Testing non-active block-commit ==='
146 # Give block-commit something to work on, otherwise it would be done
147 # immediately, send a BLOCK_JOB_COMPLETED and ejecting the BDS would work just
148 # fine without the block job still running.
150 $QEMU_IO -c 'write 0 1M' "$TEST_DIR/m.$IMGFMT" | _filter_qemu_io
153 "{'execute': 'block-commit',
154 'arguments': {'job-id': 'job0',
156 'top': '$TEST_DIR/m.$IMGFMT',
159 'BLOCK_JOB_CANCELLED'
162 echo '=== Testing block-stream ==='
165 # Give block-stream something to work on, otherwise it would be done
166 # immediately, send a BLOCK_JOB_COMPLETED and ejecting the BDS would work just
167 # fine without the block job still running.
169 $QEMU_IO -c 'write 0 1M' "$TEST_DIR/b.$IMGFMT" | _filter_qemu_io
171 # With some data to stream (and @speed set to 1), block-stream will not complete
172 # until we send the block-job-cancel command. Therefore, no event other than
173 # BLOCK_JOB_CANCELLED will be emitted.
176 "{'execute': 'block-stream',
177 'arguments': {'job-id': 'job0',
181 'BLOCK_JOB_CANCELLED'