From c7a976c5841c502aec0b95d1246c4ef8cf0a163b Mon Sep 17 00:00:00 2001 From: Andrew Bonney Date: Tue, 6 Feb 2024 08:56:33 +0000 Subject: [PATCH] Fix nova device_spec to support multiple values It appears there was a change to remove the list option when moving from pci_passthrough_whitelist. Instead device_spec can be specified multiple times in the file. This patch aims to resolve this whilst maintaining backwards compatibility. Change-Id: I12b38e45d7b41fbf4786d3320e511eb9127fe216 --- defaults/main.yml | 9 ++++----- templates/nova.conf.j2 | 8 +++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index e2d4b458..84fd7bb5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -599,11 +599,10 @@ nova_api_os_compute_uwsgi_ini_overrides: {} nova_enabled_mdev_types: "{{ nova_enabled_vgpu_types | default({}) }}" # PCI devices passthrough to nova -# For SR-IOV please use: -# nova_device_spec: '{ "physical_network": "", "devname": "" }' -# Example: -# nova_device_spec: '{ "physical_network": "physnet1", "devname": "p1p1" }' -nova_device_spec: "{{ nova_pci_passthrough_whitelist | default({}) }}" +# Example: +# nova_device_spec: +# - '{ "physical_network": "physnet1", "devname": "p1p1" }' +nova_device_spec: "{{ nova_pci_passthrough_whitelist | default([]) }}" # PCI alias, # Example: diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index f5c838b5..1174b914 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -341,8 +341,14 @@ device_addresses = {{ (record.address is string) | ternary(record.address, recor {% if nova_device_spec or nova_pci_alias %} [pci] {% if nova_device_spec %} -# White list of PCI devices available to VMs. +# PCI devices available to VMs +{% if nova_device_spec is mapping %} device_spec = {{ nova_device_spec }} +{% else %} +{% for item in nova_device_spec %} +device_spec = {{ item }} +{% endfor %} +{% endif %} {% endif %} {% if nova_pci_alias %} # PCI Alias