From 3bfc25a74e9dfbeb664eecf89d959428713eb178 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 15 Jul 2014 18:35:01 +0100 Subject: libvirt: add version cap tied to gate CI testing Limit the libvirt features that Nova will use in a default configuration to only those which are tested in the CI gate. The end user can override the limit if they wish to opt-in to use of untested features via the 'version_cap' setting in the 'libvirt' group. Change-Id: Ib91164cc572b1dbde2a31beee5751c52b0445d3e --- nova/tests/virt/libvirt/test_driver.py | 15 +++++++++++++++ nova/virt/libvirt/driver.py | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/nova/tests/virt/libvirt/test_driver.py b/nova/tests/virt/libvirt/test_driver.py index ccde7975ec..0280be9ff5 100644 --- a/nova/tests/virt/libvirt/test_driver.py +++ b/nova/tests/virt/libvirt/test_driver.py @@ -576,6 +576,21 @@ class LibvirtConnTestCase(test.TestCase, inst = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) self.assertPublicAPISignatures(inst) + def test_min_version_cap(self): + drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) + + with mock.patch.object(drvr._conn, 'getLibVersion') as mock_ver: + mock_ver.return_value = utils.convert_version_to_int((1, 5, 0)) + + self.flags(version_cap="2.0.0", group="libvirt") + self.assertTrue(drvr._has_min_version((1, 4, 0))) + + self.flags(version_cap="1.3.0", group="libvirt") + self.assertFalse(drvr._has_min_version((1, 4, 0))) + + self.flags(version_cap="", group="libvirt") + self.assertTrue(drvr._has_min_version((1, 4, 0))) + def test_set_host_enabled_with_disable(self): # Tests disabling an enabled host. conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 31712fdfd8..68889ccfa4 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -106,6 +106,11 @@ libvirt = None LOG = logging.getLogger(__name__) libvirt_opts = [ + cfg.StrOpt('version_cap', + default='1.2.2', # Must always match the version in the gate + help='Limit use of features from newer libvirt versions. ' + 'Defaults to the version that is used for automated ' + 'testing of OpenStack.'), cfg.StrOpt('rescue_image_id', help='Rescue ami image. This will not be used if an image id ' 'is provided by the user.'), @@ -413,6 +418,14 @@ class LibvirtDriver(driver.ComputeDriver): try: if lv_ver is not None: libvirt_version = conn.getLibVersion() + + if CONF.libvirt.version_cap: + libvirt_version_cap = utils.convert_version_to_int( + utils.convert_version_to_tuple( + CONF.libvirt.version_cap)) + if libvirt_version > libvirt_version_cap: + libvirt_version = libvirt_version_cap + if libvirt_version < utils.convert_version_to_int(lv_ver): return False -- cgit v1.2.1