Add group configuration to qemu.conf file

Vhost user sockets are shared between qemu and ovs. Currently,
we are patching ovs service file to make ovs run as qemu user.
In order to avoid it, a new group 'hugetlbfs' has been introduced,
which will be used by ovs and qemu. This patch allows the users
to configure the group setting for qemu.conf file.

Change-Id: I0fa3934b345d51de85fd9d8a5a211b8e1bc50d86
This commit is contained in:
Saravanan KR 2017-11-28 19:00:52 +05:30
parent 8c6ce7af30
commit 87e9b30004
3 changed files with 42 additions and 5 deletions

View File

@ -8,6 +8,10 @@
# (optional) Whether or not configure qemu bits. # (optional) Whether or not configure qemu bits.
# Defaults to false. # Defaults to false.
# #
# [*group*]
# (optional) Group under which the qemu should run.
# Defaults to undef.
#
# [*max_files*] # [*max_files*]
# (optional) Maximum number of opened files, per process. # (optional) Maximum number of opened files, per process.
# Defaults to 1024. # Defaults to 1024.
@ -18,6 +22,7 @@
# #
class nova::compute::libvirt::qemu( class nova::compute::libvirt::qemu(
$configure_qemu = false, $configure_qemu = false,
$group = undef,
$max_files = 1024, $max_files = 1024,
$max_processes = 4096, $max_processes = 4096,
){ ){
@ -34,12 +39,20 @@ class nova::compute::libvirt::qemu(
if $configure_qemu { if $configure_qemu {
$augues_changes_default = [
"set max_files ${max_files}",
"set max_processes ${max_processes}",
]
if $group and !empty($group) {
$augues_group_changes = ["set group ${group}"]
} else {
$augues_group_changes = []
}
$augues_changes = concat($augues_changes_default, $augues_group_changes)
augeas { 'qemu-conf-limits': augeas { 'qemu-conf-limits':
context => '/files/etc/libvirt/qemu.conf', context => '/files/etc/libvirt/qemu.conf',
changes => [ changes => $augues_changes,
"set max_files ${max_files}",
"set max_processes ${max_processes}",
],
tag => 'qemu-conf-augeas', tag => 'qemu-conf-augeas',
} }
} else { } else {
@ -48,6 +61,7 @@ class nova::compute::libvirt::qemu(
changes => [ changes => [
'rm max_files', 'rm max_files',
'rm max_processes', 'rm max_processes',
'rm group',
], ],
tag => 'qemu-conf-augeas', tag => 'qemu-conf-augeas',
} }

View File

@ -0,0 +1,3 @@
---
features:
- Added group parameter to configure qemu.conf

View File

@ -18,7 +18,7 @@ describe 'nova::compute::libvirt::qemu' do
end end
it { is_expected.to contain_augeas('qemu-conf-limits').with({ it { is_expected.to contain_augeas('qemu-conf-limits').with({
:context => '/files/etc/libvirt/qemu.conf', :context => '/files/etc/libvirt/qemu.conf',
:changes => [ "rm max_files", "rm max_processes" ], :changes => [ "rm max_files", "rm max_processes", "rm group" ],
}).that_notifies('Service[libvirt]') } }).that_notifies('Service[libvirt]') }
end end
@ -49,6 +49,26 @@ describe 'nova::compute::libvirt::qemu' do
:tag => 'qemu-conf-augeas', :tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') } }).that_notifies('Service[libvirt]') }
end end
context 'when configuring qemu with group parameter' do
let :params do
{
:configure_qemu => true,
:group => 'openvswitch',
:max_files => 32768,
:max_processes => 131072,
}
end
it { is_expected.to contain_augeas('qemu-conf-limits').with({
:context => '/files/etc/libvirt/qemu.conf',
:changes => [
"set max_files 32768",
"set max_processes 131072",
"set group openvswitch"
],
:tag => 'qemu-conf-augeas',
}).that_notifies('Service[libvirt]') }
end
end end
on_supported_os({ on_supported_os({