Merge "introduce "reserved_huge_pages" option"

This commit is contained in:
Zuul 2018-12-11 14:51:11 +00:00 committed by Gerrit Code Review
commit abf879d9e1
6 changed files with 77 additions and 0 deletions

View File

@ -145,6 +145,18 @@ options:
type: string
default: 'yes'
description: Whether to run nova-api and nova-network on the compute nodes.
reserved-huge-pages:
type: string
default:
description: |
Sets a reserved amont of huge pages per NUMA nodes which are used by
third-party components. Semicolons are used as separator.
.
reserved_huge_pages = node:0,size:2048,count:64;node:1,size:1GB,count:1
.
The above will consider 64 pages of 2MiB on NUMA node 0 and 1 page of
1GiB on NUMA node 1 reserved. They will not be used by Nova to map guests
memory.
pci-passthrough-whitelist:
type: string
default:

View File

@ -237,6 +237,12 @@ class NovaComputeLibvirtContext(context.OSContextGenerator):
else:
ctxt['ksm'] = "AUTO"
if config('reserved-huge-pages'):
# To bypass juju limitation with list of strings, we
# consider separate the option's values per semicolons.
ctxt['reserved_huge_pages'] = (
[o.strip() for o in config('reserved-huge-pages').split(";")])
if config('pci-passthrough-whitelist'):
ctxt['pci_passthrough_whitelist'] = \
config('pci-passthrough-whitelist')

View File

@ -119,6 +119,12 @@ vcpu_pin_set = {{ vcpu_pin_set }}
{% endif -%}
reserved_host_memory_mb = {{ reserved_host_memory }}
{% if reserved_huge_pages -%}
{% for value in reserved_huge_pages -%}
reserved_huge_pages = {{ value }}
{% endfor -%}
{% endif -%}
{% if pci_passthrough_whitelist -%}
pci_passthrough_whitelist = {{ pci_passthrough_whitelist }}
{% endif -%}

View File

@ -120,6 +120,12 @@ vcpu_pin_set = {{ vcpu_pin_set }}
{% endif -%}
reserved_host_memory_mb = {{ reserved_host_memory }}
{% if reserved_huge_pages -%}
{% for value in reserved_huge_pages -%}
reserved_huge_pages = {{ value }}
{% endfor -%}
{% endif -%}
{% if pci_passthrough_whitelist -%}
pci_passthrough_whitelist = {{ pci_passthrough_whitelist }}
{% endif -%}

View File

@ -120,6 +120,12 @@ vcpu_pin_set = {{ vcpu_pin_set }}
{% endif -%}
reserved_host_memory_mb = {{ reserved_host_memory }}
{% if reserved_huge_pages -%}
{% for value in reserved_huge_pages -%}
reserved_huge_pages = {{ value }}
{% endfor -%}
{% endif -%}
{% include "section-zeromq" %}
{% if default_availability_zone -%}

View File

@ -218,6 +218,47 @@ class NovaComputeContextTests(CharmTestCase):
'force_raw_images': True,
'reserved_host_memory': 512}, libvirt())
def test_libvirt_context_libvirtd_reserved_huge_pages_1(self):
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'yakkety'}
self.os_release.return_value = 'ocata'
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
self.test_config.set('reserved-huge-pages', 'node:0,size:2048,count:6')
libvirt = context.NovaComputeLibvirtContext()
self.assertEqual(
{'libvirtd_opts': '',
'libvirt_user': 'libvirt',
'arch': platform.machine(),
'ksm': 'AUTO',
'kvm_hugepages': 0,
'listen_tls': 0,
'host_uuid': self.host_uuid,
'force_raw_images': True,
'reserved_host_memory': 512,
'reserved_huge_pages': ['node:0,size:2048,count:6']}, libvirt())
def test_libvirt_context_libvirtd_reserved_huge_pages_2(self):
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'yakkety'}
self.os_release.return_value = 'ocata'
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
self.test_config.set(
'reserved-huge-pages',
'node:0,size:2048,count:6;node:1,size:1G,count:32')
libvirt = context.NovaComputeLibvirtContext()
self.assertEqual(
{'libvirtd_opts': '',
'libvirt_user': 'libvirt',
'arch': platform.machine(),
'ksm': 'AUTO',
'kvm_hugepages': 0,
'listen_tls': 0,
'host_uuid': self.host_uuid,
'force_raw_images': True,
'reserved_host_memory': 512,
'reserved_huge_pages': ['node:0,size:2048,count:6',
'node:1,size:1G,count:32']}, libvirt())
def test_libvirt_bin_context_no_migration(self):
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'lucid'}
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})