Merge tag 'migration-staging-pull-request' of https://gitlab.com/peterx/qemu into...
[qemu/ar7.git] / tests / qemu-iotests / 235
blob4de920c3801b05881cd1eb476ee74cf4a3fc3d86
1 #!/usr/bin/env python3
2 # group: quick
4 # Simple mirror test
6 # Copyright (c) 2018 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/>.
22 import sys
23 import os
24 import iotests
25 from iotests import qemu_img_create, qemu_io, file_path, log
27 from qemu.machine import QEMUMachine
29 iotests.script_initialize(supported_fmts=['qcow2'])
31 # Note:
32 # This test was added to check that mirror dead-lock was fixed (see previous
33 # commit before this test addition).
34 # And it didn't reproduce if at least one of the following:
35 # 1. use small image size
36 # 2. use raw format (not qcow2)
37 # 3. drop kvm and use iotests.VM() (maybe, because of qtest) (however, it still
38 #    reproduces, if just drop kvm, but gdb failed to produce full backtraces
39 #    for me)
40 # 4. add iothread
42 size = 1 * 1024 * 1024 * 1024
44 disk = file_path('disk')
46 # prepare source image
47 qemu_img_create('-f', iotests.imgfmt, '-o', 'preallocation=metadata', disk,
48                 str(size))
50 vm = QEMUMachine(iotests.qemu_prog)
51 vm.add_args('-accel', 'kvm', '-accel', 'tcg')
52 if iotests.qemu_default_machine == 's390-ccw-virtio':
53         vm.add_args('-no-shutdown')
54 vm.add_args('-drive', 'id=src,file=' + disk)
55 vm.launch()
57 log(vm.qmp('object-add', qom_type='throttle-group', id='tg0',
58            limits={'bps-total': size}))
60 log(vm.qmp('blockdev-add',
61            **{ 'node-name': 'target',
62                'driver': 'throttle',
63                'throttle-group': 'tg0',
64                'file': {
65                    'driver': 'null-co',
66                    'size': size
67                 } }))
69 log(vm.qmp('blockdev-mirror', device='src', target='target', sync='full'))
71 try:
72     vm.event_wait('BLOCK_JOB_READY', timeout=10.0)
73 except:
74     vm.shutdown()
75     raise
77 vm.shutdown()