3 # Test resume mirror after auto pause on ENOSPC
5 # Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
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 from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles
24 iotests.script_initialize(supported_fmts=['qcow2'])
26 source, target = file_path('source', 'target')
27 size = 5 * 1024 * 1024
28 limit = 2 * 1024 * 1024
30 qemu_img_create('-f', iotests.imgfmt, source, str(size))
31 qemu_img_create('-f', iotests.imgfmt, target, str(size))
32 qemu_io('-c', 'write 0 {}'.format(size), source)
34 # raw format don't like empty files
35 qemu_io('-c', 'write 0 {}'.format(size), target)
37 vm = iotests.VM().add_drive(source)
41 'driver': iotests.imgfmt,
42 'node-name': 'target',
52 vm.qmp_log('blockdev-add', filters=[filter_qmp_testfiles], **blockdev_opts)
54 vm.qmp_log('blockdev-mirror', device='drive0', sync='full', target='target',
55 on_target_error='enospc')
57 vm.event_wait('JOB_STATUS_CHANGE', timeout=3.0,
58 match={'data': {'status': 'paused'}})
60 # drop other cached events, to not interfere with further wait for 'running'
63 del blockdev_opts['file']['size']
64 vm.qmp_log('x-blockdev-reopen', filters=[filter_qmp_testfiles],
67 vm.qmp_log('block-job-resume', device='drive0')
68 vm.event_wait('JOB_STATUS_CHANGE', timeout=1.0,
69 match={'data': {'status': 'running'}})