Skip to content

Commit c7d9d6d

Browse files
committed
Fix the vGPU dynamic options race
As we lookup the existing dynamic options *before* creating them as _get_supported_vgpu_types() is called *before* compute init_host(), we need to make sure we call again the dynamic options registration within it. Change-Id: Ib9387c381d39fac389374c731b210815c6d4af03 Closes-Bug: #1900006 (cherry picked from commit 2bd8900)
1 parent 24595b6 commit c7d9d6d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24988,6 +24988,20 @@ def test_get_supported_vgpu_types_with_invalid_pci_address(self):
2498824988
libvirt_driver.LibvirtDriver,
2498924989
fake.FakeVirtAPI(), False)
2499024990

24991+
@mock.patch.object(nova.conf.devices, 'register_dynamic_opts')
24992+
def test_get_supported_vgpu_types_registering_dynamic_opts(self, rdo):
24993+
self.flags(enabled_vgpu_types=['nvidia-11', 'nvidia-12'],
24994+
group='devices')
24995+
24996+
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
24997+
drvr._get_supported_vgpu_types()
24998+
24999+
# Okay below is confusing, but remember, ._get_supported_vgpu_types()
25000+
# is first called by the LibvirtDriver object creation, so when
25001+
# calling the above drvr._get_supported_vgpu_types() method, it will
25002+
# be the second time that register_dynamic_opts() will be called.
25003+
rdo.assert_has_calls([mock.call(CONF), mock.call(CONF)])
25004+
2499125005
def test_get_vgpu_type_per_pgpu(self):
2499225006
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
2499325007
device = 'pci_0000_84_00_0'

nova/virt/libvirt/driver.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6894,6 +6894,11 @@ def _get_supported_vgpu_types(self):
68946894
if not CONF.devices.enabled_vgpu_types:
68956895
return []
68966896

6897+
# Make sure we register all the types as the compute service could
6898+
# be calling this method before init_host()
6899+
if len(CONF.devices.enabled_vgpu_types) > 1:
6900+
nova.conf.devices.register_dynamic_opts(CONF)
6901+
68976902
for vgpu_type in CONF.devices.enabled_vgpu_types:
68986903
group = getattr(CONF, 'vgpu_%s' % vgpu_type, None)
68996904
if group is None or not group.device_addresses:

0 commit comments

Comments
 (0)