blob: 2ec2416e8a0ce1f8028862ba56e86bdd2cb99608 [file] [log] [blame]
Philippe Mathieu-Daudé7c477522020-01-30 17:32:30 +01001#!/usr/bin/env python3
Vladimir Sementsov-Ogievskiy9dd003a2021-01-16 16:44:19 +03002# group: rw quick
Vladimir Sementsov-Ogievskiya66c4b82019-03-20 14:59:37 +03003#
4# Test resume mirror after auto pause on ENOSPC
5#
6# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
7#
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.
12#
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.
17#
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/>.
20#
21
22import iotests
23from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles
24
John Snow7d814052020-03-30 20:00:11 -040025iotests.script_initialize(supported_fmts=['qcow2'])
Vladimir Sementsov-Ogievskiya66c4b82019-03-20 14:59:37 +030026
27source, target = file_path('source', 'target')
28size = 5 * 1024 * 1024
29limit = 2 * 1024 * 1024
30
31qemu_img_create('-f', iotests.imgfmt, source, str(size))
32qemu_img_create('-f', iotests.imgfmt, target, str(size))
33qemu_io('-c', 'write 0 {}'.format(size), source)
34
35# raw format don't like empty files
36qemu_io('-c', 'write 0 {}'.format(size), target)
37
38vm = iotests.VM().add_drive(source)
39vm.launch()
40
41blockdev_opts = {
42 'driver': iotests.imgfmt,
43 'node-name': 'target',
44 'file': {
45 'driver': 'raw',
46 'size': limit,
47 'file': {
48 'driver': 'file',
49 'filename': target
50 }
51 }
52}
53vm.qmp_log('blockdev-add', filters=[filter_qmp_testfiles], **blockdev_opts)
54
55vm.qmp_log('blockdev-mirror', device='drive0', sync='full', target='target',
56 on_target_error='enospc')
57
58vm.event_wait('JOB_STATUS_CHANGE', timeout=3.0,
59 match={'data': {'status': 'paused'}})
60
61# drop other cached events, to not interfere with further wait for 'running'
62vm.get_qmp_events()
63
64del blockdev_opts['file']['size']
Alberto Garciae60edf62021-07-08 13:47:09 +020065vm.qmp_log('blockdev-reopen', filters=[filter_qmp_testfiles],
Alberto Garcia3908b7a2021-07-08 13:47:07 +020066 options = [ blockdev_opts ])
Vladimir Sementsov-Ogievskiya66c4b82019-03-20 14:59:37 +030067
68vm.qmp_log('block-job-resume', device='drive0')
69vm.event_wait('JOB_STATUS_CHANGE', timeout=1.0,
70 match={'data': {'status': 'running'}})
71
72vm.shutdown()