Remove hugepage fstab entry and use qemu-kvm init
The hugepages fstab entry can stop systems from booting if the /run filesystem is not available. The qemu-kvm init script can be used to enable hugepages by setting KVM_HUGEPAGES=1 This apporach works for both upstart and systemd (where the old System V script is used). However, for a systemd system the prefered approach would be to enable hugepages via kernel parameters set in MAAS. Change-Id: Ib91ca930a91da3d75dbd96f7d55e7e259cb50fd1 Closes-Bug: 1518771
This commit is contained in:
parent
d949eeda57
commit
0279111eeb
@ -257,6 +257,9 @@ options:
|
||||
description: |
|
||||
The pecentage of system memory to use for hugepages eg '10%' or the total
|
||||
number of 2M hugepages - eg "1024".
|
||||
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.
|
||||
action-managed-upgrade:
|
||||
type: boolean
|
||||
default: False
|
||||
|
@ -136,6 +136,9 @@ class NovaComputeLibvirtContext(context.OSContextGenerator):
|
||||
|
||||
if config('hugepages'):
|
||||
ctxt['hugepages'] = True
|
||||
ctxt['kvm_hugepages'] = 1
|
||||
else:
|
||||
ctxt['kvm_hugepages'] = 0
|
||||
|
||||
db = kv()
|
||||
if db.get('host_uuid'):
|
||||
|
@ -17,6 +17,7 @@ from charmhelpers.fetch import (
|
||||
apt_install,
|
||||
)
|
||||
|
||||
from charmhelpers.core.fstab import Fstab
|
||||
from charmhelpers.core.host import (
|
||||
adduser,
|
||||
add_group,
|
||||
@ -65,7 +66,6 @@ from charmhelpers.contrib.python.packages import (
|
||||
|
||||
from charmhelpers.core.hugepage import hugepage_support
|
||||
from charmhelpers.core.host import (
|
||||
fstab_mount,
|
||||
rsync,
|
||||
)
|
||||
|
||||
@ -158,6 +158,7 @@ LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf'
|
||||
LIBVIRT_BIN = '/etc/default/libvirt-bin'
|
||||
LIBVIRT_BIN_OVERRIDES = '/etc/init/libvirt-bin.override'
|
||||
NOVA_CONF = '%s/nova.conf' % NOVA_CONF_DIR
|
||||
QEMU_KVM = '/etc/default/qemu-kvm'
|
||||
|
||||
BASE_RESOURCE_MAP = {
|
||||
NOVA_CONF: {
|
||||
@ -192,6 +193,10 @@ LIBVIRT_RESOURCE_MAP = {
|
||||
'services': ['libvirt-bin'],
|
||||
'contexts': [NovaComputeLibvirtContext()],
|
||||
},
|
||||
QEMU_KVM: {
|
||||
'services': ['qemu-kvm'],
|
||||
'contexts': [NovaComputeLibvirtContext()],
|
||||
},
|
||||
LIBVIRTD_CONF: {
|
||||
'services': ['libvirt-bin'],
|
||||
'contexts': [NovaComputeLibvirtContext()],
|
||||
@ -786,8 +791,10 @@ def install_hugepages():
|
||||
mount=False,
|
||||
set_shmmax=True,
|
||||
)
|
||||
# Remove hugepages entry if present due to Bug #1518771
|
||||
Fstab.remove_by_mountpoint(mnt_point)
|
||||
if subprocess.call(['mountpoint', mnt_point]):
|
||||
fstab_mount(mnt_point)
|
||||
service_restart('qemu-kvm')
|
||||
rsync(
|
||||
charm_dir() + '/files/qemu-hugefsdir',
|
||||
'/etc/init.d/qemu-hugefsdir'
|
||||
|
6
templates/qemu-kvm
Normal file
6
templates/qemu-kvm
Normal file
@ -0,0 +1,6 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
###############################################################################
|
||||
KVM_HUGEPAGES={{ kvm_hugepages }}
|
||||
|
@ -184,6 +184,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
self.assertEqual(
|
||||
{'libvirtd_opts': '-d',
|
||||
'arch': platform.machine(),
|
||||
'kvm_hugepages': 0,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid}, libvirt())
|
||||
|
||||
@ -195,6 +196,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
self.assertEqual(
|
||||
{'libvirtd_opts': '-d -l',
|
||||
'arch': platform.machine(),
|
||||
'kvm_hugepages': 0,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid}, libvirt())
|
||||
|
||||
@ -207,6 +209,20 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
{'libvirtd_opts': '-d',
|
||||
'disk_cachemodes': 'file=unsafe,block=none',
|
||||
'arch': platform.machine(),
|
||||
'kvm_hugepages': 0,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid}, libvirt())
|
||||
|
||||
def test_libvirt_hugepages(self):
|
||||
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
|
||||
self.test_config.set('hugepages', '22')
|
||||
libvirt = context.NovaComputeLibvirtContext()
|
||||
|
||||
self.assertEqual(
|
||||
{'libvirtd_opts': '-d',
|
||||
'arch': platform.machine(),
|
||||
'hugepages': True,
|
||||
'kvm_hugepages': 1,
|
||||
'listen_tls': 0,
|
||||
'host_uuid': self.host_uuid}, libvirt())
|
||||
|
||||
|
@ -31,7 +31,7 @@ TO_PATCH = [
|
||||
'charm_dir',
|
||||
'hugepage_support',
|
||||
'rsync',
|
||||
'fstab_mount',
|
||||
'Fstab',
|
||||
]
|
||||
|
||||
openstack_origin_git = \
|
||||
@ -613,7 +613,8 @@ class NovaComputeUtilsTests(CharmTestCase):
|
||||
call(['update-rc.d', 'qemu-hugefsdir', 'defaults']),
|
||||
]
|
||||
_check_call.assert_has_calls(check_call_calls)
|
||||
self.fstab_mount.assert_called_with('/run/hugepages/kvm')
|
||||
self.Fstab.remove_by_mountpoint.assert_called_with(
|
||||
'/run/hugepages/kvm')
|
||||
|
||||
@patch('psutil.virtual_memory')
|
||||
@patch('subprocess.check_call')
|
||||
@ -631,16 +632,6 @@ class NovaComputeUtilsTests(CharmTestCase):
|
||||
set_shmmax=True,
|
||||
)
|
||||
|
||||
@patch('psutil.virtual_memory')
|
||||
@patch('subprocess.check_call')
|
||||
@patch('subprocess.call')
|
||||
def test_install_hugepages_already_mounted(self, _call, _check_call,
|
||||
_virt_mem):
|
||||
self.test_config.set('hugepages', '2048')
|
||||
_call.return_value = 0
|
||||
utils.install_hugepages()
|
||||
self.assertEqual(self.fstab_mount.call_args_list, [])
|
||||
|
||||
def test_assess_status(self):
|
||||
with patch.object(utils, 'assess_status_func') as asf:
|
||||
callee = MagicMock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user