Merge "libvirt: force config related migration flags"

This commit is contained in:
Jenkins 2016-02-02 23:01:55 +00:00 committed by Gerrit Code Review
commit 81826965ab
4 changed files with 49 additions and 1 deletions

View File

@ -91,6 +91,7 @@ VIR_CRED_EXTERNAL = 9
VIR_MIGRATE_LIVE = 1
VIR_MIGRATE_PEER2PEER = 2
VIR_MIGRATE_TUNNELLED = 4
VIR_MIGRATE_PERSIST_DEST = 8
VIR_MIGRATE_UNDEFINE_SOURCE = 16
VIR_MIGRATE_NON_SHARED_INC = 128

View File

@ -1042,6 +1042,37 @@ class LibvirtConnTestCase(test.NoDBTestCase):
msg = mock_log.warning.call_args_list[1]
self.assertIn('Removing the VIR_MIGRATE_PEER2PEER flag', msg[0][0])
@mock.patch('nova.virt.libvirt.driver.LOG')
def test_parse_migration_flags_config_mgmt(self, mock_log):
self._do_test_parse_migration_flags(
lm_config=('VIR_MIGRATE_PERSIST_DEST, '
'VIR_MIGRATE_PEER2PEER, '
'VIR_MIGRATE_LIVE, '
'VIR_MIGRATE_TUNNELLED'),
bm_config=('VIR_MIGRATE_PERSIST_DEST, '
'VIR_MIGRATE_PEER2PEER, '
'VIR_MIGRATE_LIVE, '
'VIR_MIGRATE_TUNNELLED, '
'VIR_MIGRATE_NON_SHARED_INC'),
lm_expected=(libvirt_driver.libvirt.VIR_MIGRATE_UNDEFINE_SOURCE |
libvirt_driver.libvirt.VIR_MIGRATE_PEER2PEER |
libvirt_driver.libvirt.VIR_MIGRATE_LIVE |
libvirt_driver.libvirt.VIR_MIGRATE_TUNNELLED),
bm_expected=(libvirt_driver.libvirt.VIR_MIGRATE_UNDEFINE_SOURCE |
libvirt_driver.libvirt.VIR_MIGRATE_PEER2PEER |
libvirt_driver.libvirt.VIR_MIGRATE_LIVE |
libvirt_driver.libvirt.VIR_MIGRATE_TUNNELLED |
libvirt_driver.libvirt.VIR_MIGRATE_NON_SHARED_INC))
msg = mock_log.warning.call_args_list[0]
self.assertIn('Adding the VIR_MIGRATE_UNDEFINE_SOURCE flag', msg[0][0])
msg = mock_log.warning.call_args_list[1]
self.assertIn('Removing the VIR_MIGRATE_PERSIST_DEST flag', msg[0][0])
msg = mock_log.warning.call_args_list[2]
self.assertIn('Adding the VIR_MIGRATE_UNDEFINE_SOURCE flag', msg[0][0])
msg = mock_log.warning.call_args_list[3]
self.assertIn('Removing the VIR_MIGRATE_PERSIST_DEST flag', msg[0][0])
@mock.patch('nova.utils.get_image_from_system_metadata')
@mock.patch.object(host.Host,
'has_min_version', return_value=True)

View File

@ -687,6 +687,20 @@ class LibvirtDriver(driver.ComputeDriver):
'virt_type': CONF.libvirt.virt_type})
migration_flags |= libvirt.VIR_MIGRATE_PEER2PEER
if (migration_flags & libvirt.VIR_MIGRATE_UNDEFINE_SOURCE) == 0:
LOG.warning(_LW('Adding the VIR_MIGRATE_UNDEFINE_SOURCE flag to '
'%(config_name)s because, without it, migrated '
'VMs will remain defined on the source host'),
{'config_name': config_name})
migration_flags |= libvirt.VIR_MIGRATE_UNDEFINE_SOURCE
if (migration_flags & libvirt.VIR_MIGRATE_PERSIST_DEST) != 0:
LOG.warning(_LW('Removing the VIR_MIGRATE_PERSIST_DEST flag from '
'%(config_name)s as Nova ensures the VM is '
'persisted on the destination host'),
{'config_name': config_name})
migration_flags &= ~libvirt.VIR_MIGRATE_PERSIST_DEST
return migration_flags
def _check_block_migration_flags(self, live_migration_flags,

View File

@ -6,5 +6,7 @@ upgrade:
contain VIR_MIGRATE_SHARED_INC but block_migration_flag
must contain it. Both options must contain the
VIR_MIGRATE_PEER2PEER, except when using the 'xen' virt
type this flag is not supported.
type this flag is not supported. Both flags must contain
the VIR_MIGRATE_UNDEFINE_SOURCE flag and not contain the
VIR_MIGRATE_PERSIST_DEST flag.