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