From 0b39b51ae5926aab123d78613bceb16575275b92 Mon Sep 17 00:00:00 2001 From: naichuans Date: Tue, 17 Oct 2017 10:40:29 +0000 Subject: [PATCH] vgpu: add enabled white list Some pGPUs (e.g. NVIDIA GRID K1) support different vGPU types. User can use `enabled_vgpu_types` to specify the enabled vGPU types that a guest could consume from the host. NOTE(sbauza) : Since that configuration is shared between all virt drivers, we need to provide a single change that will just add that conf opt and then use it in separate series as a common base. That implies that configuration option is useless until we merge the code that reads it, but that's a necessary compromise for making sure we can move both Xen and libvirt efforts in parallel. Partially Implements: blueprint add-support-for-vgpu Co-Authored-By: Sylvain Bauza Change-Id: I56f9597e968eac041832cdb90fe52cf0d3b4a4ef --- nova/conf/__init__.py | 2 ++ nova/conf/devices.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 nova/conf/devices.py diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 91f7b7d8e342..6b2fcb82747e 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -32,6 +32,7 @@ from nova.conf import console from nova.conf import consoleauth from nova.conf import crypto from nova.conf import database +from nova.conf import devices from nova.conf import ephemeral_storage from nova.conf import flavors from nova.conf import glance @@ -84,6 +85,7 @@ console.register_opts(CONF) consoleauth.register_opts(CONF) crypto.register_opts(CONF) database.register_opts(CONF) +devices.register_opts(CONF) ephemeral_storage.register_opts(CONF) flavors.register_opts(CONF) glance.register_opts(CONF) diff --git a/nova/conf/devices.py b/nova/conf/devices.py new file mode 100644 index 000000000000..0974eedbb129 --- /dev/null +++ b/nova/conf/devices.py @@ -0,0 +1,40 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_config import cfg + +devices_group = cfg.OptGroup( + name='devices', + title='physical or virtual device options') + +vgpu_opts = [ + cfg.ListOpt('enabled_vgpu_types', + default=[], + help=""" +A list of the vGPU types enabled in the compute node. + +Some pGPUs (e.g. NVIDIA GRID K1) support different vGPU types. User can use +this option to specify a list of enabled vGPU types that may be assigned to a +guest instance. An example is as the following: + [devices] + enabled_vgpu_types = ['GRID K100', 'Intel GVT-g', 'MxGPU.2', 'nvidia-11'] +""") +] + + +def register_opts(conf): + conf.register_group(devices_group) + conf.register_opts(vgpu_opts, group=devices_group) + + +def list_opts(): + return {devices_group: vgpu_opts}