Merge remote-tracking branch 'remotes/awilliam/tags/vfio-fixes-20190702.0' into staging
[qemu/ar7.git] / tests / qemu-iotests / 248
blobf26b4bb2aad7b8867a994616e08d6907c6bef8f4
1 #!/usr/bin/env python
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/>.
21 import iotests
22 from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles
24 iotests.verify_image_format(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)
38 vm.launch()
40 blockdev_opts = {
41 'driver': iotests.imgfmt,
42 'node-name': 'target',
43 'file': {
44 'driver': 'raw',
45 'size': limit,
46 'file': {
47 'driver': 'file',
48 'filename': 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'
61 vm.get_qmp_events()
63 del blockdev_opts['file']['size']
64 vm.qmp_log('x-blockdev-reopen', filters=[filter_qmp_testfiles],
65 **blockdev_opts)
67 vm.qmp_log('block-job-resume', device='drive0')
68 vm.event_wait('JOB_STATUS_CHANGE', timeout=1.0,
69 match={'data': {'status': 'running'}})
71 vm.shutdown()