From 2eabf254f3af13ff7dbc942f8e60af353db650b8 Mon Sep 17 00:00:00 2001 From: Zhang Hua Date: Thu, 16 Feb 2017 15:30:18 +0800 Subject: [PATCH] Add pci-alias option Add a new pci-alias option which supports the use of PCI devices in flavors. This allows, for example, a GPU or a SR-IOV device to be automatically allocated to an instance using a specific flavor. Change-Id: I249ba04085d37657df0c8e3bb21723a388f08938 Closes-Bug: 1649868 --- config.yaml | 17 +++++++++++++++++ hooks/nova_cc_context.py | 2 ++ templates/kilo/nova.conf | 3 +++ templates/liberty/nova.conf | 3 +++ templates/mitaka/nova.conf | 3 +++ templates/ocata/nova.conf | 5 +++++ 6 files changed, 33 insertions(+) diff --git a/config.yaml b/config.yaml index fe016e5f..501e6873 100644 --- a/config.yaml +++ b/config.yaml @@ -416,6 +416,23 @@ options: description: | List of filter class names to use for filtering hosts when not specified in the request. + pci-alias: + type: string + default: + description: | + The pci-passthrough-whitelist option of nova-compute charm is used for + specifying which PCI devices are allowed passthrough. pci-alias is more + a convenience that can be used in conjunction with Nova flavor properties + to automatically assign required PCI devices to new instances. You could, + for example, have a GPU flavor or a SR-IOV flavor: + + pci-alias='{"vendor_id":"8086","product_id":"10ca","name":"a1"}' + + This configures a new PCI alias 'a1' which will request a PCI device with + a vendor id of 0x8086 and a product id of 10ca. + + For more information about the syntax of pci_alias, refer to + https://docs.openstack.org/ocata/config-reference/compute/config-options.html api-rate-limit-rules: type: string default: diff --git a/hooks/nova_cc_context.py b/hooks/nova_cc_context.py index b971e545..8c416827 100644 --- a/hooks/nova_cc_context.py +++ b/hooks/nova_cc_context.py @@ -261,6 +261,8 @@ class NovaConfigContext(context.WorkerConfigContext): def __call__(self): ctxt = super(NovaConfigContext, self).__call__() ctxt['scheduler_default_filters'] = config('scheduler-default-filters') + if config('pci-alias'): + ctxt['pci_alias'] = config('pci-alias') ctxt['cpu_allocation_ratio'] = config('cpu-allocation-ratio') ctxt['ram_allocation_ratio'] = config('ram-allocation-ratio') addr = resolve_address(INTERNAL) diff --git a/templates/kilo/nova.conf b/templates/kilo/nova.conf index 31c1af97..5b0c7bf0 100644 --- a/templates/kilo/nova.conf +++ b/templates/kilo/nova.conf @@ -35,6 +35,9 @@ scheduler_default_filters = {{ scheduler_default_filters }},{{ additional_neutro {% else %} scheduler_default_filters = {{ scheduler_default_filters }} {% endif %} +{% if pci_alias %} +pci_alias = {{ pci_alias }} +{% endif %} cpu_allocation_ratio = {{ cpu_allocation_ratio }} ram_allocation_ratio = {{ ram_allocation_ratio }} diff --git a/templates/liberty/nova.conf b/templates/liberty/nova.conf index 92c11bb3..347946b0 100644 --- a/templates/liberty/nova.conf +++ b/templates/liberty/nova.conf @@ -35,6 +35,9 @@ scheduler_default_filters = {{ scheduler_default_filters }},{{ additional_neutro {% else %} scheduler_default_filters = {{ scheduler_default_filters }} {% endif %} +{% if pci_alias %} +pci_alias = {{ pci_alias }} +{% endif %} cpu_allocation_ratio = {{ cpu_allocation_ratio }} ram_allocation_ratio = {{ ram_allocation_ratio }} diff --git a/templates/mitaka/nova.conf b/templates/mitaka/nova.conf index e4134a1f..b10dd129 100644 --- a/templates/mitaka/nova.conf +++ b/templates/mitaka/nova.conf @@ -32,6 +32,9 @@ scheduler_default_filters = {{ scheduler_default_filters }},{{ additional_neutro {% else %} scheduler_default_filters = {{ scheduler_default_filters }} {% endif %} +{% if pci_alias %} +pci_alias = {{ pci_alias }} +{% endif %} cpu_allocation_ratio = {{ cpu_allocation_ratio }} ram_allocation_ratio = {{ ram_allocation_ratio }} diff --git a/templates/ocata/nova.conf b/templates/ocata/nova.conf index 61b7630d..13da9028 100644 --- a/templates/ocata/nova.conf +++ b/templates/ocata/nova.conf @@ -183,3 +183,8 @@ auth_strategy=keystone [wsgi] api_paste_config=/etc/nova/api-paste.ini + +[pci] +{% if pci_alias %} +alias = {{ pci_alias }} +{% endif %}