Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu/rayw.git] / tests / qemu-iotests / 262
bloba4a92de45a1729bff74a423b1883af3b502803e5
1 #!/usr/bin/env python3
2 # group: rw quick migration
4 # Copyright (C) 2019 Red Hat, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 # Creator/Owner: Kevin Wolf <kwolf@redhat.com>
21 # Test migration with filter drivers present. Keep everything in an
22 # iothread just for fun.
24 import iotests
25 import os
27 iotests.script_initialize(supported_fmts=['qcow2'],
28                           supported_platforms=['linux'],
29                           required_fmts=['blkverify'])
31 with iotests.FilePath('img') as img_path, \
32      iotests.FilePath('mig_fifo') as fifo, \
33      iotests.VM(path_suffix='a') as vm_a, \
34      iotests.VM(path_suffix='b') as vm_b:
36     def add_opts(vm):
37         vm.add_object('iothread,id=iothread0')
38         vm.add_object('throttle-group,id=tg0,x-bps-total=65536')
39         vm.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
40         vm.add_blockdev('%s,file=drive0-file,node-name=drive0-fmt' % (iotests.imgfmt))
41         vm.add_blockdev('copy-on-read,file=drive0-fmt,node-name=drive0-cor')
42         vm.add_blockdev('throttle,file=drive0-cor,node-name=drive0-throttle,throttle-group=tg0')
43         vm.add_blockdev('blkdebug,image=drive0-throttle,node-name=drive0-dbg')
44         vm.add_blockdev('null-co,node-name=null,read-zeroes=on')
45         vm.add_blockdev('blkverify,test=drive0-dbg,raw=null,node-name=drive0-verify')
47         if iotests.supports_quorum():
48             vm.add_blockdev('quorum,children.0=drive0-verify,vote-threshold=1,node-name=drive0-quorum')
49             root = "drive0-quorum"
50         else:
51             root = "drive0-verify"
53         vm.add_device('virtio-blk,drive=%s,iothread=iothread0' % root)
55     iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M')
57     os.mkfifo(fifo)
59     iotests.log('Launching destination VM...')
60     add_opts(vm_b)
61     vm_b.add_incoming("exec: cat '%s'" % (fifo))
62     vm_b.launch()
64     vm_b.enable_migration_events('B')
66     iotests.log('Launching source VM...')
67     add_opts(vm_a)
68     vm_a.launch()
70     vm_a.enable_migration_events('A')
72     iotests.log('Starting migration to B...')
73     iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo)))
74     with iotests.Timeout(3, 'Migration does not complete'):
75         # Wait for the source first (which includes setup=setup)
76         vm_a.wait_migration('postmigrate')
77         # Wait for the destination second (which does not)
78         vm_b.wait_migration('running')
80     iotests.log(vm_a.qmp('query-migrate')['return']['status'])
81     iotests.log(vm_b.qmp('query-migrate')['return']['status'])
83     iotests.log(vm_a.qmp('query-status'))
84     iotests.log(vm_b.qmp('query-status'))