libqos: add MSI-X callbacks to QVirtioPCIDevice
[qemu/ar7.git] / tests / qemu-iotests / 234
blob34c818c4854d4d52c3409bedc2f2469d4abcaaed
1 #!/usr/bin/env python
3 # Copyright (C) 2018 Red Hat, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Creator/Owner: Kevin Wolf <kwolf@redhat.com>
20 # Check that block node activation and inactivation works with a block graph
21 # that is built with individually created nodes
23 import iotests
24 import os
26 iotests.verify_image_format(supported_fmts=['qcow2'])
27 iotests.verify_platform(['linux'])
29 with iotests.FilePath('img') as img_path, \
30 iotests.FilePath('backing') as backing_path, \
31 iotests.FilePath('mig_fifo_a') as fifo_a, \
32 iotests.FilePath('mig_fifo_b') as fifo_b, \
33 iotests.VM(path_suffix='a') as vm_a, \
34 iotests.VM(path_suffix='b') as vm_b:
36 iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, backing_path, '64M')
37 iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M')
39 os.mkfifo(fifo_a)
40 os.mkfifo(fifo_b)
42 iotests.log('Launching source VM...')
43 (vm_a.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
44 .add_blockdev('%s,file=drive0-file,node-name=drive0' % (iotests.imgfmt))
45 .add_blockdev('file,filename=%s,node-name=drive0-backing-file' % (backing_path))
46 .add_blockdev('%s,file=drive0-backing-file,node-name=drive0-backing' % (iotests.imgfmt))
47 .launch())
49 vm_a.enable_migration_events('A')
51 iotests.log('Launching destination VM...')
52 (vm_b.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
53 .add_blockdev('%s,file=drive0-file,node-name=drive0' % (iotests.imgfmt))
54 .add_blockdev('file,filename=%s,node-name=drive0-backing-file' % (backing_path))
55 .add_blockdev('%s,file=drive0-backing-file,node-name=drive0-backing' % (iotests.imgfmt))
56 .add_incoming("exec: cat '%s'" % (fifo_a))
57 .launch())
59 vm_b.enable_migration_events('B')
61 # Add a child node that was created after the parent node. The reverse case
62 # is covered by the -blockdev options above.
63 iotests.log(vm_a.qmp('blockdev-snapshot', node='drive0-backing',
64 overlay='drive0'))
65 iotests.log(vm_b.qmp('blockdev-snapshot', node='drive0-backing',
66 overlay='drive0'))
68 iotests.log('Starting migration to B...')
69 iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo_a)))
70 with iotests.Timeout(3, 'Migration does not complete'):
71 # Wait for the source first (which includes setup=setup)
72 vm_a.wait_migration()
73 # Wait for the destination second (which does not)
74 vm_b.wait_migration()
76 iotests.log(vm_a.qmp('query-migrate')['return']['status'])
77 iotests.log(vm_b.qmp('query-migrate')['return']['status'])
79 iotests.log(vm_a.qmp('query-status'))
80 iotests.log(vm_b.qmp('query-status'))
82 iotests.log('Add a second parent to drive0-file...')
83 iotests.log(vm_b.qmp('blockdev-add', driver='raw', file='drive0-file',
84 node_name='drive0-raw'))
86 iotests.log('Restart A with -incoming and second parent...')
87 vm_a.shutdown()
88 (vm_a.add_blockdev('raw,file=drive0-file,node-name=drive0-raw')
89 .add_incoming("exec: cat '%s'" % (fifo_b))
90 .launch())
92 vm_a.enable_migration_events('A')
94 iotests.log(vm_a.qmp('blockdev-snapshot', node='drive0-backing',
95 overlay='drive0'))
97 iotests.log('Starting migration back to A...')
98 iotests.log(vm_b.qmp('migrate', uri='exec:cat >%s' % (fifo_b)))
99 with iotests.Timeout(3, 'Migration does not complete'):
100 # Wait for the source first (which includes setup=setup)
101 vm_b.wait_migration()
102 # Wait for the destination second (which does not)
103 vm_a.wait_migration()
105 iotests.log(vm_a.qmp('query-migrate')['return']['status'])
106 iotests.log(vm_b.qmp('query-migrate')['return']['status'])
108 iotests.log(vm_a.qmp('query-status'))
109 iotests.log(vm_b.qmp('query-status'))