Skip to content

Commit ff4d0d0

Browse files
committed
Rename vgpu options to mdev
As a prerequisite for blueprint generic-mdevs we need to rename the existing enabled_vgpu_types options and dynamically generated groups into enabled_mdev_types. There is no upgrade impact for existing users, as the original options are still accepted. NOTE(sbauza): As we have a lot of methods and objects named gpu-ish let's just change what we need here and provide followups for fixing internal tech debt later. Change-Id: Idba094f6366a24965804b88da0bc1b9754549c99 Partially-Implements: blueprint generic-mdevs
1 parent 3545356 commit ff4d0d0

File tree

8 files changed

+122
-105
lines changed

8 files changed

+122
-105
lines changed

doc/source/admin/virtual-gpu.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,25 @@ Enable GPU types (Compute)
3333

3434
#. Specify which specific GPU type(s) the instances would get.
3535

36-
Edit :oslo.config:option:`devices.enabled_vgpu_types`:
36+
Edit :oslo.config:option:`devices.enabled_mdev_types`:
3737

3838
.. code-block:: ini
3939
4040
[devices]
41-
enabled_vgpu_types = nvidia-35
41+
enabled_mdev_types = nvidia-35
4242
4343
If you want to support more than a single GPU type, you need to provide a
4444
separate configuration section for each device. For example:
4545

4646
.. code-block:: ini
4747
4848
[devices]
49-
enabled_vgpu_types = nvidia-35, nvidia-36
49+
enabled_mdev_types = nvidia-35, nvidia-36
5050
51-
[vgpu_nvidia-35]
51+
[mdev_nvidia-35]
5252
device_addresses = 0000:84:00.0,0000:85:00.0
5353
54-
[vgpu_nvidia-36]
54+
[mdev_nvidia-36]
5555
device_addresses = 0000:86:00.0
5656
5757
where you have to define which physical GPUs are supported per GPU type.

nova/conf/devices.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,39 @@
1616
name='devices',
1717
title='physical or virtual device options')
1818

19-
vgpu_opts = [
20-
cfg.ListOpt('enabled_vgpu_types',
19+
mdev_opts = [
20+
cfg.ListOpt('enabled_mdev_types',
2121
default=[],
22+
deprecated_name='enabled_vgpu_types',
2223
help="""
23-
The vGPU types enabled in the compute node.
24+
The mdev types enabled in the compute node.
2425
25-
Some pGPUs (e.g. NVIDIA GRID K1) support different vGPU types. User can use
26-
this option to specify a list of enabled vGPU types that may be assigned to a
26+
Some hardware (e.g. NVIDIA GRID K1) support different mdev types. User can use
27+
this option to specify a list of enabled mdev types that may be assigned to a
2728
guest instance.
2829
29-
If more than one single vGPU type is provided, then for each *vGPU type* an
30-
additional section, ``[vgpu_$(VGPU_TYPE)]``, must be added to the configuration
30+
If more than one single mdev type is provided, then for each *mdev type* an
31+
additional section, ``[mdev_$(MDEV_TYPE)]``, must be added to the configuration
3132
file. Each section then **must** be configured with a single configuration
3233
option, ``device_addresses``, which should be a list of PCI addresses
33-
corresponding to the physical GPU(s) to assign to this type.
34+
corresponding to the physical GPU(s) or mdev-capable hardware to assign to this
35+
type.
3436
3537
If one or more sections are missing (meaning that a specific type is not wanted
36-
to use for at least one physical GPU) or if no device addresses are provided,
37-
then Nova will only use the first type that was provided by
38-
``[devices]/enabled_vgpu_types``.
38+
to use for at least one physical device) or if no device addresses are provided
39+
, then Nova will only use the first type that was provided by
40+
``[devices]/enabled_mdev_types``.
3941
4042
If the same PCI address is provided for two different types, nova-compute will
4143
return an InvalidLibvirtGPUConfig exception at restart.
4244
43-
An example is as the following::
45+
As an interim period, old configuration groups named ``[vgpu_$(MDEV_TYPE)]``
46+
will be accepted. A valid configuration could then be::
4447
4548
[devices]
46-
enabled_vgpu_types = nvidia-35, nvidia-36
49+
enabled_mdev_types = nvidia-35, nvidia-36
4750
48-
[vgpu_nvidia-35]
51+
[mdev_nvidia-35]
4952
device_addresses = 0000:84:00.0,0000:85:00.0
5053
5154
[vgpu_nvidia-36]
@@ -57,7 +60,7 @@
5760

5861
def register_opts(conf):
5962
conf.register_group(devices_group)
60-
conf.register_opts(vgpu_opts, group=devices_group)
63+
conf.register_opts(mdev_opts, group=devices_group)
6164

6265

6366
def register_dynamic_opts(conf):
@@ -66,14 +69,15 @@ def register_dynamic_opts(conf):
6669
This must be called by the service that wishes to use the options **after**
6770
the initial configuration has been loaded.
6871
"""
69-
opt = cfg.ListOpt('device_addresses', default=[],
70-
item_type=cfg.types.String())
7172

72-
# Register the '[vgpu_$(VGPU_TYPE)]/device_addresses' opts, implicitly
73-
# registering the '[vgpu_$(VGPU_TYPE)]' groups in the process
74-
for vgpu_type in conf.devices.enabled_vgpu_types:
75-
conf.register_opt(opt, group='vgpu_%s' % vgpu_type)
73+
# Register the '[mdev_$(MDEV_TYPE)]/device_addresses' opts, implicitly
74+
# registering the '[mdev_$(MDEV_TYPE)]' groups in the process
75+
for mdev_type in conf.devices.enabled_mdev_types:
76+
opt = cfg.ListOpt('device_addresses', default=[],
77+
item_type=cfg.types.String(),
78+
deprecated_group='vgpu_%s' % mdev_type)
79+
conf.register_opt(opt, group='mdev_%s' % mdev_type)
7680

7781

7882
def list_opts():
79-
return {devices_group: vgpu_opts}
83+
return {devices_group: mdev_opts}

nova/tests/functional/libvirt/test_reshape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_create_servers_with_vgpu(
7979

8080
# start a compute with vgpu support disabled so the driver will
8181
# ignore the content of the above HostMdevDeviceInfo
82-
self.flags(enabled_vgpu_types='', group='devices')
82+
self.flags(enabled_mdev_types='', group='devices')
8383

8484
hostname = self.start_compute(
8585
hostname='compute1',
@@ -106,7 +106,7 @@ def test_create_servers_with_vgpu(
106106

107107
# enabled vgpu support
108108
self.flags(
109-
enabled_vgpu_types=fakelibvirt.NVIDIA_11_VGPU_TYPE,
109+
enabled_mdev_types=fakelibvirt.NVIDIA_11_VGPU_TYPE,
110110
group='devices')
111111
# We don't want to restart the compute service or it would call for
112112
# a reshape but we still want to accept some vGPU types so we call

nova/tests/functional/libvirt/test_vgpu.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def setUp(self):
132132

133133
# Start compute1 supporting only nvidia-11
134134
self.flags(
135-
enabled_vgpu_types=fakelibvirt.NVIDIA_11_VGPU_TYPE,
135+
enabled_mdev_types=fakelibvirt.NVIDIA_11_VGPU_TYPE,
136136
group='devices')
137137

138138
# for the sake of resizing, we need to patch the two methods below
@@ -293,7 +293,7 @@ def setUp(self):
293293
self.flavor = self._create_flavor(extra_spec=extra_spec)
294294

295295
self.flags(
296-
enabled_vgpu_types=[fakelibvirt.NVIDIA_11_VGPU_TYPE,
296+
enabled_mdev_types=[fakelibvirt.NVIDIA_11_VGPU_TYPE,
297297
fakelibvirt.NVIDIA_12_VGPU_TYPE],
298298
group='devices')
299299
# we need to call the below again to ensure the updated
@@ -304,8 +304,8 @@ def setUp(self):
304304
# - 0000:81:01.0 will only support nvidia-12
305305
pgpu1_pci_addr = self.libvirt2pci_address(fakelibvirt.PGPU1_PCI_ADDR)
306306
pgpu2_pci_addr = self.libvirt2pci_address(fakelibvirt.PGPU2_PCI_ADDR)
307-
self.flags(device_addresses=[pgpu1_pci_addr], group='vgpu_nvidia-11')
308-
self.flags(device_addresses=[pgpu2_pci_addr], group='vgpu_nvidia-12')
307+
self.flags(device_addresses=[pgpu1_pci_addr], group='mdev_nvidia-11')
308+
self.flags(device_addresses=[pgpu2_pci_addr], group='mdev_nvidia-12')
309309

310310
# Prepare traits for later on
311311
self._create_trait('CUSTOM_NVIDIA_11')

nova/tests/unit/conf/test_devices.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
class DevicesConfTestCase(test.NoDBTestCase):
2121

2222
def test_register_dynamic_opts(self):
23-
self.flags(enabled_vgpu_types=['nvidia-11', 'nvidia-12'],
23+
self.flags(enabled_mdev_types=['nvidia-11', 'nvidia-12'],
2424
group='devices')
2525

26-
self.assertNotIn('vgpu_nvidia-11', CONF)
27-
self.assertNotIn('vgpu_nvidia-12', CONF)
26+
self.assertNotIn('mdev_nvidia-11', CONF)
27+
self.assertNotIn('mdev_nvidia-12', CONF)
2828

2929
nova.conf.devices.register_dynamic_opts(CONF)
3030

31-
self.assertIn('vgpu_nvidia-11', CONF)
32-
self.assertIn('vgpu_nvidia-12', CONF)
33-
self.assertEqual([], getattr(CONF, 'vgpu_nvidia-11').device_addresses)
34-
self.assertEqual([], getattr(CONF, 'vgpu_nvidia-12').device_addresses)
31+
self.assertIn('mdev_nvidia-11', CONF)
32+
self.assertIn('mdev_nvidia-12', CONF)
33+
self.assertEqual([], getattr(CONF, 'mdev_nvidia-11').device_addresses)
34+
self.assertEqual([], getattr(CONF, 'mdev_nvidia-12').device_addresses)

0 commit comments

Comments
 (0)