]> Git Repo - qemu.git/blob - tests/qemu-iotests/248
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
[qemu.git] / tests / qemu-iotests / 248
1 #!/usr/bin/env python
2 #
3 # Test resume mirror after auto pause on ENOSPC
4 #
5 # Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
6 #
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.
11 #
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.
16 #
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/>.
19 #
20
21 import iotests
22 from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles
23
24 iotests.verify_image_format(supported_fmts=['qcow2'])
25
26 source, target = file_path('source', 'target')
27 size = 5 * 1024 * 1024
28 limit = 2 * 1024 * 1024
29
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)
33
34 # raw format don't like empty files
35 qemu_io('-c', 'write 0 {}'.format(size), target)
36
37 vm = iotests.VM().add_drive(source)
38 vm.launch()
39
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
49         }
50     }
51 }
52 vm.qmp_log('blockdev-add', filters=[filter_qmp_testfiles], **blockdev_opts)
53
54 vm.qmp_log('blockdev-mirror', device='drive0', sync='full', target='target',
55            on_target_error='enospc')
56
57 vm.event_wait('JOB_STATUS_CHANGE', timeout=3.0,
58               match={'data': {'status': 'paused'}})
59
60 # drop other cached events, to not interfere with further wait for 'running'
61 vm.get_qmp_events()
62
63 del blockdev_opts['file']['size']
64 vm.qmp_log('x-blockdev-reopen', filters=[filter_qmp_testfiles],
65            **blockdev_opts)
66
67 vm.qmp_log('block-job-resume', device='drive0')
68 vm.event_wait('JOB_STATUS_CHANGE', timeout=1.0,
69               match={'data': {'status': 'running'}})
70
71 vm.shutdown()
This page took 0.030461 seconds and 4 git commands to generate.