From 3edfbe68963f26a2c11b87094504f8ab37e0abcc Mon Sep 17 00:00:00 2001 From: Danny Meloy Date: Mon, 21 Dec 2020 17:44:35 +0000 Subject: [PATCH] Add Virtual GPU Config to nova.conf template Currently, the list of supported vGPUs is populated automatically within the Nova playbook when the /sys/class/mdev_bus folder is present. This will populate the `enabled_vgpu_types` variable with the full list of vGPUs that are supported by default, with only the first one listed being used. This change provides the ability to define a new variable `nova_enabled_vgpu_types` that will populate the enabled_vgpu_types config option. It also adds the ability to map vgpu types to PCI addresses in line with Ussuri updates to provide multi-vGPU support. Change-Id: Icc0c2cd896d4c9a01601d4d733f38443ad8400d4 --- defaults/main.yml | 14 ++++++++++++++ tasks/nova_vgpu_detect.yml | 2 +- templates/nova.conf.j2 | 9 +++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 2b007353..5e52f986 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -506,6 +506,20 @@ nova_vendor_data_overrides: {} nova_api_metadata_uwsgi_ini_overrides: {} nova_api_os_compute_uwsgi_ini_overrides: {} +# Enabled vGPU Types - dict defining 'type' and 'address' (optional) of vGPU +# an address is only required when supporting more than one physical GPU on the host +# Example 1: +# nova_enabled_vgpu_types: +# - type: nvidia-35 +# +# Example 2: +# nova_enabled_vgpu_types: +# - type: nvidia-35 +# address: +# - type: nvidia-36 +# address: +nova_enabled_vgpu_types: {} + # PCI devices passthrough to nova # For SR-IOV please use: # nova_pci_passthrough_whitelist: '{ "physical_network": "", "devname": "" }' diff --git a/tasks/nova_vgpu_detect.yml b/tasks/nova_vgpu_detect.yml index c64166cf..5b547b69 100644 --- a/tasks/nova_vgpu_detect.yml +++ b/tasks/nova_vgpu_detect.yml @@ -24,7 +24,7 @@ - name: Register a fact for nova enabled_vgpu_types set_fact: - enabled_vgpu_types: "{{ mdev.stdout_lines | unique }}" + discovered_vgpu_types: "{{ mdev.stdout_lines | unique }}" when: - mdev.stdout_lines is defined - mdev.stdout_lines | length > 0 diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index 17e43997..e9e17678 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -293,9 +293,14 @@ tracks_instance_changes = {{ nova_scheduler_tracks_instance_changes }} [upgrade_levels] compute=auto -{% if enabled_vgpu_types is defined %} +{% if nova_enabled_vgpu_types | length > 0 or discovered_vgpu_types is defined %} [devices] -enabled_vgpu_types = {{ enabled_vgpu_types | join(',') }} +enabled_vgpu_types = {{ nova_enabled_vgpu_types | map(attribute='type') | list | default(discovered_vgpu_types, true) | unique | join(',') }} + +{% for record in nova_enabled_vgpu_types | selectattr('address', 'defined') | list %} +[vgpu_{{ record.type }}] +device_addresses = {{ record.address }} +{% endfor %} {% endif %} {% if nova_pci_passthrough_whitelist or nova_pci_alias %}