Merge "Exposes new ksm config directive."
This commit is contained in:
commit
a0c736680d
@ -308,6 +308,13 @@ options:
|
||||
For a systemd system (wily and later) the prefered approach is to enable
|
||||
hugepages via kernel parameters set in MAAS and systemd will mount them
|
||||
automatically.
|
||||
ksm:
|
||||
type: string
|
||||
default: "AUTO"
|
||||
description: |
|
||||
Set to 1 to enable KSM, 0 to disable KSM, and AUTO to use default settings.
|
||||
Please note that the AUTO value works for qemu 2.2+ (> Kilo), older
|
||||
releases will be set to 1 as default.
|
||||
action-managed-upgrade:
|
||||
type: boolean
|
||||
default: False
|
||||
|
@ -33,6 +33,7 @@ from charmhelpers.core.hookenv import (
|
||||
related_units,
|
||||
service_name,
|
||||
ERROR,
|
||||
INFO,
|
||||
)
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
get_os_version_package,
|
||||
@ -191,6 +192,16 @@ class NovaComputeLibvirtContext(context.OSContextGenerator):
|
||||
else:
|
||||
ctxt['kvm_hugepages'] = 0
|
||||
|
||||
if config('ksm') in ("1", "0",):
|
||||
ctxt['ksm'] = config('ksm')
|
||||
else:
|
||||
if release < 'kilo':
|
||||
log("KSM set to 1 by default on openstack releases < kilo",
|
||||
level=INFO)
|
||||
ctxt['ksm'] = "1"
|
||||
else:
|
||||
ctxt['ksm'] = "AUTO"
|
||||
|
||||
if config('pci-passthrough-whitelist'):
|
||||
ctxt['pci_passthrough_whitelist'] = \
|
||||
config('pci-passthrough-whitelist')
|
||||
|
@ -2,5 +2,15 @@
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
###############################################################################
|
||||
# Set to 1 to enable KSM, 0 to disable KSM, and AUTO to use default settings.
|
||||
# After changing this setting restart the qemu-kvm service.
|
||||
KSM_ENABLED={{ ksm }}
|
||||
SLEEP_MILLISECS=200
|
||||
# To load the vhost_net module, which in some cases can speed up
|
||||
# network performance, set VHOST_NET_ENABLED to 1.
|
||||
VHOST_NET_ENABLED=0
|
||||
|
||||
# Set this to 1 if you want hugepages to be available to kvm under
|
||||
# /run/hugepages/kvm
|
||||
KVM_HUGEPAGES={{ kvm_hugepages }}
|
||||
|
||||
|
@ -76,6 +76,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NovaComputeContextTests, self).setUp(context, TO_PATCH)
|
||||
self.os_release.return_value = 'kilo'
|
||||
self.relation_get.side_effect = self.test_relation.get
|
||||
self.config.side_effect = self.test_config.get
|
||||
self.log.side_effect = fake_log
|
||||
@ -202,6 +203,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
{'libvirtd_opts': '',
|
||||
'libvirt_user': 'libvirt',
|
||||
'arch': platform.machine(),
|
||||
'ksm': 'AUTO',
|
||||
'kvm_hugepages': 0,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid,
|
||||
@ -216,6 +218,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
{'libvirtd_opts': '-d',
|
||||
'libvirt_user': 'libvirtd',
|
||||
'arch': platform.machine(),
|
||||
'ksm': 'AUTO',
|
||||
'kvm_hugepages': 0,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid,
|
||||
@ -230,6 +233,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
{'libvirtd_opts': '-d -l',
|
||||
'libvirt_user': 'libvirtd',
|
||||
'arch': platform.machine(),
|
||||
'ksm': 'AUTO',
|
||||
'kvm_hugepages': 0,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid,
|
||||
@ -245,6 +249,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
'libvirt_user': 'libvirtd',
|
||||
'disk_cachemodes': 'file=unsafe,block=none',
|
||||
'arch': platform.machine(),
|
||||
'ksm': 'AUTO',
|
||||
'kvm_hugepages': 0,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid,
|
||||
@ -260,6 +265,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
'libvirt_user': 'libvirtd',
|
||||
'arch': platform.machine(),
|
||||
'hugepages': True,
|
||||
'ksm': 'AUTO',
|
||||
'kvm_hugepages': 1,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid,
|
||||
@ -342,6 +348,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
{'libvirtd_opts': '-d',
|
||||
'libvirt_user': 'libvirtd',
|
||||
'arch': platform.machine(),
|
||||
'ksm': 'AUTO',
|
||||
'hugepages': True,
|
||||
'kvm_hugepages': 1,
|
||||
'listen_tls': 0,
|
||||
@ -350,6 +357,38 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
'vcpu_pin_set': '^0^2',
|
||||
'pci_passthrough_whitelist': 'mypcidevices'}, libvirt())
|
||||
|
||||
def test_ksm_configs(self):
|
||||
self.test_config.set('ksm', '1')
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertTrue(libvirt()['ksm'] == '1')
|
||||
|
||||
self.test_config.set('ksm', '0')
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertTrue(libvirt()['ksm'] == '0')
|
||||
|
||||
self.test_config.set('ksm', 'AUTO')
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertTrue(libvirt()['ksm'] == 'AUTO')
|
||||
|
||||
self.test_config.set('ksm', '')
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertTrue(libvirt()['ksm'] == 'AUTO')
|
||||
|
||||
self.os_release.return_value = 'ocata'
|
||||
self.test_config.set('ksm', 'AUTO')
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertTrue(libvirt()['ksm'] == 'AUTO')
|
||||
|
||||
self.os_release.return_value = 'kilo'
|
||||
self.test_config.set('ksm', 'AUTO')
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertTrue(libvirt()['ksm'] == 'AUTO')
|
||||
|
||||
self.os_release.return_value = 'cactus'
|
||||
self.test_config.set('ksm', 'AUTO')
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
self.assertTrue(libvirt()['ksm'] == '1')
|
||||
|
||||
@patch.object(context.uuid, 'uuid4')
|
||||
def test_libvirt_cpu_mode_default(self, mock_uuid):
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
|
Loading…
x
Reference in New Issue
Block a user