2020-01-30 17:32:30 +01:00
|
|
|
#!/usr/bin/env python3
|
2021-01-16 14:44:19 +01:00
|
|
|
# group: quick migration
|
2018-11-26 12:21:07 +01:00
|
|
|
#
|
|
|
|
# Copyright (C) 2018 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# Creator/Owner: Kevin Wolf <kwolf@redhat.com>
|
|
|
|
#
|
|
|
|
# Check that block node activation and inactivation works with a block graph
|
|
|
|
# that is built with individually created nodes
|
|
|
|
|
|
|
|
import iotests
|
|
|
|
import os
|
|
|
|
|
2020-03-31 02:00:11 +02:00
|
|
|
iotests.script_initialize(supported_fmts=['qcow2'],
|
|
|
|
supported_platforms=['linux'])
|
2018-11-26 12:21:07 +01:00
|
|
|
|
|
|
|
with iotests.FilePath('img') as img_path, \
|
|
|
|
iotests.FilePath('backing') as backing_path, \
|
|
|
|
iotests.FilePath('mig_fifo_a') as fifo_a, \
|
|
|
|
iotests.FilePath('mig_fifo_b') as fifo_b, \
|
|
|
|
iotests.VM(path_suffix='a') as vm_a, \
|
|
|
|
iotests.VM(path_suffix='b') as vm_b:
|
|
|
|
|
2022-03-21 21:16:12 +01:00
|
|
|
iotests.qemu_img_create('-f', iotests.imgfmt, backing_path, '64M')
|
|
|
|
iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M')
|
2018-11-26 12:21:07 +01:00
|
|
|
|
|
|
|
os.mkfifo(fifo_a)
|
|
|
|
os.mkfifo(fifo_b)
|
|
|
|
|
|
|
|
iotests.log('Launching source VM...')
|
|
|
|
(vm_a.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
|
|
|
|
.add_blockdev('%s,file=drive0-file,node-name=drive0' % (iotests.imgfmt))
|
|
|
|
.add_blockdev('file,filename=%s,node-name=drive0-backing-file' % (backing_path))
|
|
|
|
.add_blockdev('%s,file=drive0-backing-file,node-name=drive0-backing' % (iotests.imgfmt))
|
|
|
|
.launch())
|
|
|
|
|
2019-08-01 13:14:09 +02:00
|
|
|
vm_a.enable_migration_events('A')
|
2018-12-21 19:42:26 +01:00
|
|
|
|
2018-11-26 12:21:07 +01:00
|
|
|
iotests.log('Launching destination VM...')
|
|
|
|
(vm_b.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
|
|
|
|
.add_blockdev('%s,file=drive0-file,node-name=drive0' % (iotests.imgfmt))
|
|
|
|
.add_blockdev('file,filename=%s,node-name=drive0-backing-file' % (backing_path))
|
|
|
|
.add_blockdev('%s,file=drive0-backing-file,node-name=drive0-backing' % (iotests.imgfmt))
|
|
|
|
.add_incoming("exec: cat '%s'" % (fifo_a))
|
|
|
|
.launch())
|
|
|
|
|
2019-08-01 13:14:09 +02:00
|
|
|
vm_b.enable_migration_events('B')
|
2018-12-21 19:42:26 +01:00
|
|
|
|
2018-11-26 12:21:07 +01:00
|
|
|
# Add a child node that was created after the parent node. The reverse case
|
|
|
|
# is covered by the -blockdev options above.
|
|
|
|
iotests.log(vm_a.qmp('blockdev-snapshot', node='drive0-backing',
|
|
|
|
overlay='drive0'))
|
|
|
|
iotests.log(vm_b.qmp('blockdev-snapshot', node='drive0-backing',
|
|
|
|
overlay='drive0'))
|
|
|
|
|
|
|
|
iotests.log('Starting migration to B...')
|
|
|
|
iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo_a)))
|
|
|
|
with iotests.Timeout(3, 'Migration does not complete'):
|
2018-12-21 19:42:26 +01:00
|
|
|
# Wait for the source first (which includes setup=setup)
|
2019-12-19 19:36:17 +01:00
|
|
|
vm_a.wait_migration('postmigrate')
|
2018-12-21 19:42:26 +01:00
|
|
|
# Wait for the destination second (which does not)
|
2019-12-19 19:36:17 +01:00
|
|
|
vm_b.wait_migration('running')
|
2018-11-26 12:21:07 +01:00
|
|
|
|
|
|
|
iotests.log(vm_a.qmp('query-migrate')['return']['status'])
|
|
|
|
iotests.log(vm_b.qmp('query-migrate')['return']['status'])
|
|
|
|
|
|
|
|
iotests.log(vm_a.qmp('query-status'))
|
|
|
|
iotests.log(vm_b.qmp('query-status'))
|
|
|
|
|
|
|
|
iotests.log('Add a second parent to drive0-file...')
|
|
|
|
iotests.log(vm_b.qmp('blockdev-add', driver='raw', file='drive0-file',
|
|
|
|
node_name='drive0-raw'))
|
|
|
|
|
|
|
|
iotests.log('Restart A with -incoming and second parent...')
|
|
|
|
vm_a.shutdown()
|
|
|
|
(vm_a.add_blockdev('raw,file=drive0-file,node-name=drive0-raw')
|
|
|
|
.add_incoming("exec: cat '%s'" % (fifo_b))
|
|
|
|
.launch())
|
|
|
|
|
2019-08-01 13:14:09 +02:00
|
|
|
vm_a.enable_migration_events('A')
|
2018-12-21 19:42:26 +01:00
|
|
|
|
2018-11-26 12:21:07 +01:00
|
|
|
iotests.log(vm_a.qmp('blockdev-snapshot', node='drive0-backing',
|
|
|
|
overlay='drive0'))
|
|
|
|
|
|
|
|
iotests.log('Starting migration back to A...')
|
|
|
|
iotests.log(vm_b.qmp('migrate', uri='exec:cat >%s' % (fifo_b)))
|
|
|
|
with iotests.Timeout(3, 'Migration does not complete'):
|
2018-12-21 19:42:26 +01:00
|
|
|
# Wait for the source first (which includes setup=setup)
|
2019-12-19 19:36:17 +01:00
|
|
|
vm_b.wait_migration('postmigrate')
|
2018-12-21 19:42:26 +01:00
|
|
|
# Wait for the destination second (which does not)
|
2019-12-19 19:36:17 +01:00
|
|
|
vm_a.wait_migration('running')
|
2018-11-26 12:21:07 +01:00
|
|
|
|
|
|
|
iotests.log(vm_a.qmp('query-migrate')['return']['status'])
|
|
|
|
iotests.log(vm_b.qmp('query-migrate')['return']['status'])
|
|
|
|
|
|
|
|
iotests.log(vm_a.qmp('query-status'))
|
|
|
|
iotests.log(vm_b.qmp('query-status'))
|