diff --git a/nova/tests/unit/virt/libvirt/fakelibvirt.py b/nova/tests/unit/virt/libvirt/fakelibvirt.py index 7cbcd5264096..085064b892df 100644 --- a/nova/tests/unit/virt/libvirt/fakelibvirt.py +++ b/nova/tests/unit/virt/libvirt/fakelibvirt.py @@ -150,7 +150,7 @@ VIR_SECRET_USAGE_TYPE_CEPH = 2 VIR_SECRET_USAGE_TYPE_ISCSI = 3 # Libvirt version -FAKE_LIBVIRT_VERSION = 9011 +FAKE_LIBVIRT_VERSION = 10002 class HostInfo(object): @@ -790,7 +790,7 @@ class DomainSnapshot(object): class Connection(object): - def __init__(self, uri=None, readonly=False, version=9011, + def __init__(self, uri=None, readonly=False, version=FAKE_LIBVIRT_VERSION, hv_version=1001000, host_info=None): if not uri or uri == '': if allow_default_uri_connection: diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 6d366fbf6a8a..7364aae643f0 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -742,12 +742,21 @@ class LibvirtConnTestCase(test.NoDBTestCase): @mock.patch.object(libvirt_driver.LOG, 'warning') def test_next_min_version_deprecation_warning(self, mock_warning, mock_get_libversion): + # Skip test if there's no currently planned new min version + if (versionutils.convert_version_to_int( + libvirt_driver.NEXT_MIN_LIBVIRT_VERSION) == + versionutils.convert_version_to_int( + libvirt_driver.MIN_LIBVIRT_VERSION)): + self.skipTest("NEXT_MIN_LIBVIRT_VERSION == MIN_LIBVIRT_VERSION") + # Test that a warning is logged if the libvirt version is less than # the next required minimum version. drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) drvr.init_host("dummyhost") # assert that the next min version is in a warning message - expected_arg = {'version': '0.10.2'} + expected_arg = {'version': versionutils.convert_version_to_str( + versionutils.convert_version_to_int( + libvirt_driver.NEXT_MIN_LIBVIRT_VERSION))} version_arg_found = False for call in mock_warning.call_args_list: if call[0][1] == expected_arg: @@ -760,12 +769,22 @@ class LibvirtConnTestCase(test.NoDBTestCase): libvirt_driver.NEXT_MIN_LIBVIRT_VERSION)) @mock.patch.object(libvirt_driver.LOG, 'warning') def test_next_min_version_ok(self, mock_warning, mock_get_libversion): + # Skip test if there's no currently planned new min version + + if (versionutils.convert_version_to_int( + libvirt_driver.NEXT_MIN_LIBVIRT_VERSION) == + versionutils.convert_version_to_int( + libvirt_driver.MIN_LIBVIRT_VERSION)): + self.skipTest("NEXT_MIN_LIBVIRT_VERSION == MIN_LIBVIRT_VERSION") + # Test that a warning is not logged if the libvirt version is greater # than or equal to NEXT_MIN_LIBVIRT_VERSION. drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) drvr.init_host("dummyhost") # assert that the next min version is in a warning message - expected_arg = {'version': '0.10.2'} + expected_arg = {'version': versionutils.convert_version_to_str( + versionutils.convert_version_to_int( + libvirt_driver.NEXT_MIN_LIBVIRT_VERSION))} version_arg_found = False for call in mock_warning.call_args_list: if call[0][1] == expected_arg: @@ -5134,24 +5153,6 @@ class LibvirtConnTestCase(test.NoDBTestCase): instance, "/dev/sda") - @mock.patch.object(fakelibvirt.virConnect, "getLibVersion") - def test_attach_blockio_invalid_version(self, mock_version): - mock_version.return_value = (0 * 1000 * 1000) + (9 * 1000) + 8 - self.flags(virt_type='qemu', group='libvirt') - self.create_fake_libvirt_mock() - libvirt_driver.LibvirtDriver._conn.lookupByName = self.fake_lookup - instance = objects.Instance(**self.test_instance) - self.mox.ReplayAll() - drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) - self.assertRaises(exception.Invalid, - drvr.attach_volume, None, - {"driver_volume_type": "fake", - "data": {"logical_block_size": "4096", - "physical_block_size": "4096"} - }, - instance, - "/dev/sda") - @mock.patch('nova.utils.get_image_from_system_metadata') @mock.patch('nova.virt.libvirt.blockinfo.get_info_from_bdm') @mock.patch('nova.virt.libvirt.host.Host.get_domain') @@ -8011,7 +8012,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): return def fake_getLibVersion(): - return 9011 + return fakelibvirt.FAKE_LIBVIRT_VERSION def fake_getCapabilities(): return """ @@ -11764,7 +11765,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.resultXML = None def fake_getLibVersion(): - return 9011 + return fakelibvirt.FAKE_LIBVIRT_VERSION def fake_getCapabilities(): return """ diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 56712ccce46f..d69306573fa1 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -354,20 +354,33 @@ def patch_tpool_proxy(): patch_tpool_proxy() -# This is effectively the min version for i686/x86_64 + KVM/QEMU +# For information about when MIN_LIBVIRT_VERSION and +# NEXT_MIN_LIBVIRT_VERSION can be changed, consult +# +# https://wiki.openstack.org/wiki/LibvirtDistroSupportMatrix +# +# Currently this is effectively the min version for i686/x86_64 +# + KVM/QEMU, as other architectures/hypervisors require newer +# versions. Over time, this will become a common min version +# for all architectures/hypervisors, as this value rises to +# meet them. +# # TODO(berrange) find out what min version ppc64 needs as it # almost certainly wants something newer than this.... -MIN_LIBVIRT_VERSION = (0, 9, 11) +MIN_LIBVIRT_VERSION = (0, 10, 2) +# TODO(berrange): Re-evaluate this at start of each release cycle +# to decide if we want to plan a future min version bump. +# MIN_LIBVIRT_VERSION can be updated to match this after +# NEXT_MIN_LIBVIRT_VERSION has been at a higher value for +# one cycle +NEXT_MIN_LIBVIRT_VERSION = (1, 2, 1) + # When the above version matches/exceeds this version # delete it & corresponding code using it MIN_LIBVIRT_DEVICE_CALLBACK_VERSION = (1, 1, 1) -# TODO(mriedem): Change MIN_LIB_VERSION to this in the 13.0.0 'M' release. -NEXT_MIN_LIBVIRT_VERSION = (0, 10, 2) # Live snapshot requirements MIN_LIBVIRT_LIVESNAPSHOT_VERSION = (1, 0, 0) MIN_QEMU_LIVESNAPSHOT_VERSION = (1, 3, 0) -# block size tuning requirements -MIN_LIBVIRT_BLOCKIO_VERSION = (0, 10, 2) # BlockJobInfo management requirement MIN_LIBVIRT_BLOCKJOBINFO_VERSION = (1, 1, 1) # Relative block commit & rebase (feature is detected, @@ -592,14 +605,13 @@ class LibvirtDriver(driver.ComputeDriver): 'libvirt version %s') % self._version_to_string(MIN_LIBVIRT_PARALLELS_VERSION)) - # TODO(mriedem): We plan to move to a minimum required version of - # libvirt 0.10.2 in the 13.0.0 'M' release so if we're running with - # less than that now, log a warning. + # Give the cloud admin a heads up if we are intending to + # change the MIN_LIBVIRT_VERSION in the next release. if not self._host.has_min_version(NEXT_MIN_LIBVIRT_VERSION): LOG.warning(_LW('Running Nova with a libvirt version less than ' '%(version)s is deprecated. The required minimum ' 'version of libvirt will be raised to %(version)s ' - 'in the 13.0.0 release.'), + 'in the next release.'), {'version': self._version_to_string( NEXT_MIN_LIBVIRT_VERSION)}) @@ -1109,12 +1121,6 @@ class LibvirtDriver(driver.ComputeDriver): "block size") % CONF.libvirt.virt_type raise exception.InvalidHypervisorType(msg) - if not self._host.has_min_version(MIN_LIBVIRT_BLOCKIO_VERSION): - ver = ".".join([str(x) for x in MIN_LIBVIRT_BLOCKIO_VERSION]) - msg = _("Volume sets block size, but libvirt '%s' or later is " - "required.") % ver - raise exception.Invalid(msg) - disk_info = blockinfo.get_info_from_bdm( instance, CONF.libvirt.virt_type, image_meta, bdm) self._connect_volume(connection_info, disk_info) diff --git a/releasenotes/notes/min_libvirt_bump-d9916d9c4512dd11.yaml b/releasenotes/notes/min_libvirt_bump-d9916d9c4512dd11.yaml new file mode 100644 index 000000000000..cddf00195dc1 --- /dev/null +++ b/releasenotes/notes/min_libvirt_bump-d9916d9c4512dd11.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - The minimum required libvirt is now version 0.10.2. The minimum + libvirt for the N release has been set to 1.2.1.