Skip to content

Commit 7132882

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "libvirt: Remove MIN_{QEMU,LIBVIRT}_LUKS_VERSION"
2 parents e75598b + 616bfa9 commit 7132882

File tree

2 files changed

+6
-45
lines changed

2 files changed

+6
-45
lines changed

nova/tests/unit/virt/libvirt/test_driver.py

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8566,7 +8566,7 @@ def test_detach_encryptor_native_luks_device_path_secret_missing(self,
85668566
@mock.patch.object(host.Host, "has_min_version")
85678567
def test_use_native_luks(self, mock_has_min_version):
85688568
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
8569-
# True only when the required QEMU and Libvirt versions are available
8569+
# The required QEMU and Libvirt versions are always available
85708570
# on the host and a valid LUKS provider is present within the
85718571
# encryption metadata dict.
85728572
mock_has_min_version.return_value = True
@@ -8585,24 +8585,6 @@ def test_use_native_luks(self, mock_has_min_version):
85858585
self.assertTrue(drvr._use_native_luks({
85868586
'provider': encryptors.LUKS}))
85878587

8588-
# Always False when the required QEMU and Libvirt versions are not
8589-
# available on the host.
8590-
mock_has_min_version.return_value = False
8591-
self.assertFalse(drvr._use_native_luks({}))
8592-
self.assertFalse(drvr._use_native_luks({
8593-
'provider': 'nova.volume.encryptors.cryptsetup.CryptSetupEncryptor'
8594-
}))
8595-
self.assertFalse(drvr._use_native_luks({
8596-
'provider': 'CryptSetupEncryptor'}))
8597-
self.assertFalse(drvr._use_native_luks({
8598-
'provider': encryptors.PLAIN}))
8599-
self.assertFalse(drvr._use_native_luks({
8600-
'provider': 'nova.volume.encryptors.luks.LuksEncryptor'}))
8601-
self.assertFalse(drvr._use_native_luks({
8602-
'provider': 'LuksEncryptor'}))
8603-
self.assertFalse(drvr._use_native_luks({
8604-
'provider': encryptors.LUKS}))
8605-
86068588
def test_multi_nic(self):
86078589
network_info = _fake_network_info(self, 2)
86088590
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@@ -12083,13 +12065,6 @@ def test_pre_live_migration_only_dest_supports_native_luks(self):
1208312065
src_supports_native_luks=None, dest_supports_native_luks=True,
1208412066
allow_native_luks=False)
1208512067

12086-
def test_pre_live_migration_only_src_supports_native_luks(self):
12087-
# Assert that allow_native_luks is False when dest_supports_native_luks
12088-
# is False due to unmet QEMU and Libvirt deps on the dest compute.
12089-
self._test_pre_live_migration_works_correctly_mocked(
12090-
src_supports_native_luks=True, dest_supports_native_luks=False,
12091-
allow_native_luks=False)
12092-
1209312068
@mock.patch.object(libvirt_driver.LibvirtDriver, 'plug_vifs')
1209412069
@mock.patch.object(libvirt_driver.LibvirtDriver, '_connect_volume')
1209512070
@mock.patch('nova.virt.libvirt.utils.file_open',
@@ -12145,9 +12120,6 @@ def fixed_ips(self):
1214512120
self.stub_out('nova.virt.libvirt.driver.LibvirtDriver.'
1214612121
'_create_images_and_backing',
1214712122
lambda *args, **kwargs: None)
12148-
self.stub_out('nova.virt.libvirt.driver.LibvirtDriver.'
12149-
'_is_native_luks_available',
12150-
lambda self: dest_supports_native_luks)
1215112123

1215212124
nw_info = FakeNetworkInfo()
1215312125

@@ -12309,14 +12281,12 @@ def _test_pre_live_migration_volume_backed(self, encrypted_volumes=False):
1230912281

1231012282
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
1231112283
with test.nested(
12312-
mock.patch.object(drvr, '_is_native_luks_available'),
1231312284
mock.patch.object(drvr._host, 'find_secret'),
1231412285
mock.patch.object(drvr, '_connect_volume'),
1231512286
mock.patch.object(drvr, 'plug_vifs'),
12316-
) as (mock_is_luks_available, mock_find_secret,
12317-
mock_connect_volume, mock_plug_vifs):
12287+
) as (mock_find_secret, mock_connect_volume,
12288+
mock_plug_vifs):
1231812289

12319-
mock_is_luks_available.return_value = True
1232012290
mock_find_secret.return_value = None
1232112291
if encrypted_volumes:
1232212292
secret_vol1 = mock.Mock()

nova/virt/libvirt/driver.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,6 @@ def repr_method(self):
270270
# for details.
271271
MIN_LIBVIRT_MULTIATTACH = (3, 10, 0)
272272

273-
MIN_LIBVIRT_LUKS_VERSION = (2, 2, 0)
274-
MIN_QEMU_LUKS_VERSION = (2, 6, 0)
275-
276273
MIN_LIBVIRT_FILE_BACKED_VERSION = (4, 0, 0)
277274
MIN_QEMU_FILE_BACKED_VERSION = (2, 6, 0)
278275

@@ -764,10 +761,6 @@ def _handle_native_tls(self, migration_flags):
764761
migration_flags |= libvirt.VIR_MIGRATE_TLS
765762
return migration_flags
766763

767-
def _is_native_luks_available(self):
768-
return self._host.has_min_version(MIN_LIBVIRT_LUKS_VERSION,
769-
MIN_QEMU_LUKS_VERSION)
770-
771764
def _handle_live_migration_post_copy(self, migration_flags):
772765
if CONF.libvirt.live_migration_permit_post_copy:
773766
migration_flags |= libvirt.VIR_MIGRATE_POSTCOPY
@@ -1421,14 +1414,14 @@ def _extend_volume(self, connection_info, instance, requested_size):
14211414
requested_size)
14221415

14231416
def _use_native_luks(self, encryption=None):
1424-
"""Is LUKS the required provider and native QEMU LUKS available
1417+
"""Check if LUKS is the required 'provider'
14251418
"""
14261419
provider = None
14271420
if encryption:
14281421
provider = encryption.get('provider', None)
14291422
if provider in encryptors.LEGACY_PROVIDER_CLASS_TO_FORMAT_MAP:
14301423
provider = encryptors.LEGACY_PROVIDER_CLASS_TO_FORMAT_MAP[provider]
1431-
return provider == encryptors.LUKS and self._is_native_luks_available()
1424+
return provider == encryptors.LUKS
14321425

14331426
def _get_volume_config(self, connection_info, disk_info):
14341427
vol_driver = self._get_volume_driver(connection_info)
@@ -8394,10 +8387,8 @@ def pre_live_migration(self, context, instance, block_device_info,
83948387
src_native_luks = False
83958388
if migrate_data.obj_attr_is_set('src_supports_native_luks'):
83968389
src_native_luks = migrate_data.src_supports_native_luks
8397-
dest_native_luks = self._is_native_luks_available()
8398-
allow_native_luks = src_native_luks and dest_native_luks
83998390
self._connect_volume(context, connection_info, instance,
8400-
allow_native_luks=allow_native_luks)
8391+
allow_native_luks=src_native_luks)
84018392

84028393
self._pre_live_migration_plug_vifs(
84038394
instance, network_info, migrate_data)

0 commit comments

Comments
 (0)