Always manage hugetlbfs mountpoint for libvirt

hugetlbfs mountpoint value should be set to the only correct value when huge
pages are enabled (other values are prohibited by apparmor) and removed when
huge pages are disabled

Change-Id: I84dd96c8268e1c8610a1f4788616441f0c0ebce0
Closes-bug: #1556083
This commit is contained in:
Sergey Kolekonov 2016-03-14 15:32:47 +03:00
parent 0f92581240
commit b2e12dd096
2 changed files with 18 additions and 4 deletions

View File

@ -185,14 +185,21 @@ class openstack::compute (
if $::osfamily == 'Debian' { if $::osfamily == 'Debian' {
if $use_huge_pages { if $use_huge_pages {
$qemu_hugepages_value = 'set KVM_HUGEPAGES 1' $qemu_hugepages_value = 'set KVM_HUGEPAGES 1'
$libvirt_hugetlbfs_mount = 'set hugetlbfs_mount /run/hugepages/kvm'
} else { } else {
$qemu_hugepages_value = 'rm KVM_HUGEPAGES' $qemu_hugepages_value = 'rm KVM_HUGEPAGES'
$libvirt_hugetlbfs_mount = 'rm hugetlbfs_mount'
} }
augeas { 'qemu_hugepages': augeas { 'qemu_hugepages':
context => '/files/etc/default/qemu-kvm', context => '/files/etc/default/qemu-kvm',
changes => $qemu_hugepages_value, changes => $qemu_hugepages_value,
notify => Service['libvirt'], notify => Service['libvirt'],
} }
augeas { 'libvirt_hugetlbfs_mount':
context => '/files/etc/libvirt/qemu.conf',
changes => $libvirt_hugetlbfs_mount,
notify => Service['libvirt'],
}
Augeas['qemu_hugepages'] ~> Service<| title == 'qemu-kvm'|> Augeas['qemu_hugepages'] ~> Service<| title == 'qemu-kvm'|>
Service<| title == 'qemu-kvm'|> -> Service<| title == 'libvirt'|> Service<| title == 'qemu-kvm'|> -> Service<| title == 'libvirt'|>

View File

@ -157,8 +157,10 @@ describe manifest do
it 'should set up huge pages support for qemu-kvm' do it 'should set up huge pages support for qemu-kvm' do
if enable_hugepages if enable_hugepages
qemu_hugepages_value = 'set KVM_HUGEPAGES 1' qemu_hugepages_value = 'set KVM_HUGEPAGES 1'
libvirt_hugetlbfs_mount = 'set hugetlbfs_mount /run/hugepages/kvm'
else else
qemu_hugepages_value = 'rm KVM_HUGEPAGES' qemu_hugepages_value = 'rm KVM_HUGEPAGES'
libvirt_hugetlbfs_mount = 'rm hugetlbfs_mount'
end end
if facts[:osfamily] == 'Debian' if facts[:osfamily] == 'Debian'
@ -167,6 +169,11 @@ describe manifest do
'changes' => qemu_hugepages_value, 'changes' => qemu_hugepages_value,
).that_notifies('Service[libvirt]') ).that_notifies('Service[libvirt]')
should contain_augeas('libvirt_hugetlbfs_mount').with(
'context' => '/files/etc/libvirt/qemu.conf',
'changes' => libvirt_hugetlbfs_mount,
).that_notifies('Service[libvirt]')
should contain_augeas('qemu_hugepages').that_notifies('Service[qemu-kvm]') should contain_augeas('qemu_hugepages').that_notifies('Service[qemu-kvm]')
should contain_service('qemu-kvm').that_comes_before('Service[libvirt]') should contain_service('qemu-kvm').that_comes_before('Service[libvirt]')
end end