From df334b4f414b8c341709df37ca10065d3b50fcef Mon Sep 17 00:00:00 2001 From: Pawel Koniszewski Date: Wed, 11 Jan 2017 17:43:40 +0100 Subject: [PATCH] Add new configuration option live_migration_scheme This change adds a new configuration option to change scheme that is used for live migrations. The change also deprecates old live_migration_uri in favor of two other flags: * live_migraton_inbound_addr to configure live migration target URI * live_migration_scheme to change scheme used for live migration The new configuration option does not break backward compatibility as it does not override scheme set in live_migration_uri. Change-Id: I38b3d1d42b2ffc4a2f6d7398061829d3c745b9a1 --- nova/conf/libvirt.py | 24 +++++++++++++++++++ nova/tests/unit/virt/libvirt/test_driver.py | 15 ++++++++++++ nova/virt/libvirt/driver.py | 18 ++++++++++---- ...e_live_migration_uri-8ae6656664db5ba0.yaml | 13 ++++++++++ 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/deprecate_live_migration_uri-8ae6656664db5ba0.yaml diff --git a/nova/conf/libvirt.py b/nova/conf/libvirt.py index 2ecd152e356c..81504d4d0dfa 100644 --- a/nova/conf/libvirt.py +++ b/nova/conf/libvirt.py @@ -259,6 +259,13 @@ Possible values: # TODO(hieulq): change to URIOpt for validating schemas with next release # of oslo_config. cfg.StrOpt('live_migration_uri', + deprecated_for_removal=True, + deprecated_since="15.0.0", + deprecated_reason=""" +live_migration_uri is deprecated for removal in favor of two other options that +allow to change live migration scheme and target URI: ``live_migration_scheme`` +and ``live_migration_inbound_addr`` respectively. +""", help=""" Live migration target URI to use. @@ -277,6 +284,23 @@ Related options: * ``live_migration_inbound_addr``: If ``live_migration_inbound_addr`` value is not None, the ip/hostname address of target compute node is used instead of ``live_migration_uri`` as the uri for live migration. +* ``live_migration_scheme``: If ``live_migration_uri`` is not set, the scheme + used for live migration is taken from ``live_migration_scheme`` instead. +"""), + cfg.StrOpt('live_migration_scheme', + help=""" +Schema used for live migration. + +Override the default libvirt live migration scheme (which is dependant on +virt_type). If this option is set to None, nova will automatically choose a +sensible default based on the hypervisor. It is not recommended that you change +this unless you are very sure that hypervisor supports a particular scheme. + +Related options: +* ``virt_type``: This option is meaningful only when ``virt_type`` is set to + `kvm` or `qemu`. +* ``live_migration_uri``: If ``live_migration_uri`` value is not None, the + scheme used for live migration is taken from ``live_migration_uri`` instead. """), cfg.BoolOpt('live_migration_tunnelled', default=False, diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 3e90f4ed1d6e..c086a18349f8 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -7825,6 +7825,21 @@ class LibvirtConnTestCase(test.NoDBTestCase): drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) self.assertEqual(forced_uri % dest, drvr._live_migration_uri(dest)) + def test_live_migration_scheme(self): + self.flags(live_migration_scheme='ssh', group='libvirt') + dest = 'destination' + uri = 'qemu+ssh://%s/system' + drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) + self.assertEqual(uri % dest, drvr._live_migration_uri(dest)) + + def test_live_migration_scheme_does_not_override_uri(self): + forced_uri = 'qemu+ssh://%s/system' + self.flags(live_migration_uri=forced_uri, group='libvirt') + self.flags(live_migration_scheme='tcp', group='libvirt') + dest = 'destination' + drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) + self.assertEqual(forced_uri % dest, drvr._live_migration_uri(dest)) + def test_migrate_uri(self): hypervisor_uri_map = ( ('xen', None), diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index d6a9be657cb9..9fe422fc0324 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -684,15 +684,25 @@ class LibvirtDriver(driver.ComputeDriver): # Only Xen and QEMU support live migration, see # https://libvirt.org/migration.html#scenarios for reference uris = { - 'kvm': 'qemu+tcp://%s/system', - 'qemu': 'qemu+tcp://%s/system', + 'kvm': 'qemu+%s://%s/system', + 'qemu': 'qemu+%s://%s/system', 'xen': 'xenmigr://%s/system', } virt_type = CONF.libvirt.virt_type - uri = CONF.libvirt.live_migration_uri or uris.get(virt_type) + # TODO(pkoniszewski): Remove fetching live_migration_uri in Pike + uri = CONF.libvirt.live_migration_uri + if uri: + return uri % dest + + uri = uris.get(virt_type) if uri is None: raise exception.LiveMigrationURINotAvailable(virt_type=virt_type) - return uri % dest + + str_format = (dest,) + if virt_type in ('kvm', 'qemu'): + scheme = CONF.libvirt.live_migration_scheme or 'tcp' + str_format = (scheme, dest) + return uris.get(virt_type) % str_format @staticmethod def _migrate_uri(dest): diff --git a/releasenotes/notes/deprecate_live_migration_uri-8ae6656664db5ba0.yaml b/releasenotes/notes/deprecate_live_migration_uri-8ae6656664db5ba0.yaml new file mode 100644 index 000000000000..4444aa4ebbef --- /dev/null +++ b/releasenotes/notes/deprecate_live_migration_uri-8ae6656664db5ba0.yaml @@ -0,0 +1,13 @@ +--- +deprecations: + - | + The ``live_migration_uri`` option in the [libvirt] configuration section + is deprecated, and will be removed in a future release. The + ``live_migration_scheme`` should be used to change scheme used for live + migration, and ``live_migration_inbound_addr`` should be used to change + target URI. +features: + - | + The libvirt driver now has a ``live_migration_scheme`` configuration + option which should be used where the ``live_migration_uri`` would + previously have been configured with non-default scheme.