Philippe Mathieu-Daudé | 7c47752 | 2020-01-30 17:32:30 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Vladimir Sementsov-Ogievskiy | 9dd003a | 2021-01-16 16:44:19 +0300 | [diff] [blame] | 2 | # group: rw quick |
Vladimir Sementsov-Ogievskiy | a66c4b8 | 2019-03-20 14:59:37 +0300 | [diff] [blame] | 3 | # |
| 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 | |
| 22 | import iotests |
| 23 | from iotests import qemu_img_create, qemu_io, file_path, filter_qmp_testfiles |
| 24 | |
John Snow | 7d81405 | 2020-03-30 20:00:11 -0400 | [diff] [blame] | 25 | iotests.script_initialize(supported_fmts=['qcow2']) |
Vladimir Sementsov-Ogievskiy | a66c4b8 | 2019-03-20 14:59:37 +0300 | [diff] [blame] | 26 | |
| 27 | source, target = file_path('source', 'target') |
| 28 | size = 5 * 1024 * 1024 |
| 29 | limit = 2 * 1024 * 1024 |
| 30 | |
| 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) |
| 34 | |
| 35 | # raw format don't like empty files |
| 36 | qemu_io('-c', 'write 0 {}'.format(size), target) |
| 37 | |
| 38 | vm = iotests.VM().add_drive(source) |
| 39 | vm.launch() |
| 40 | |
| 41 | blockdev_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 | } |
| 53 | vm.qmp_log('blockdev-add', filters=[filter_qmp_testfiles], **blockdev_opts) |
| 54 | |
| 55 | vm.qmp_log('blockdev-mirror', device='drive0', sync='full', target='target', |
| 56 | on_target_error='enospc') |
| 57 | |
| 58 | vm.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' |
| 62 | vm.get_qmp_events() |
| 63 | |
| 64 | del blockdev_opts['file']['size'] |
Alberto Garcia | e60edf6 | 2021-07-08 13:47:09 +0200 | [diff] [blame] | 65 | vm.qmp_log('blockdev-reopen', filters=[filter_qmp_testfiles], |
Alberto Garcia | 3908b7a | 2021-07-08 13:47:07 +0200 | [diff] [blame] | 66 | options = [ blockdev_opts ]) |
Vladimir Sementsov-Ogievskiy | a66c4b8 | 2019-03-20 14:59:37 +0300 | [diff] [blame] | 67 | |
| 68 | vm.qmp_log('block-job-resume', device='drive0') |
| 69 | vm.event_wait('JOB_STATUS_CHANGE', timeout=1.0, |
| 70 | match={'data': {'status': 'running'}}) |
| 71 | |
| 72 | vm.shutdown() |