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 <sbauza@redhat.com>

Change-Id: I56f9597e968eac041832cdb90fe52cf0d3b4a4ef
This commit is contained in:
naichuans 2017-10-17 10:40:29 +00:00 committed by Jianghua Wang
parent 497da9f90f
commit 0b39b51ae5
2 changed files with 42 additions and 0 deletions

View File

@ -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)

40
nova/conf/devices.py Normal file
View File

@ -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}