From a4e72119c3fda26c3671cc03b487308484fd77ec Mon Sep 17 00:00:00 2001 From: Saravanan KR Date: Tue, 28 Nov 2017 19:00:52 +0530 Subject: [PATCH] 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 (cherry picked from commit 87e9b300045bb708baf1f0216e6261470de3f04f) --- manifests/compute/libvirt/qemu.pp | 22 +++++++++++++++---- .../libvirt-qemu-group-8430caa099147529.yaml | 3 +++ .../classes/nova_compute_libvirt_qemu_spec.rb | 22 ++++++++++++++++++- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/libvirt-qemu-group-8430caa099147529.yaml diff --git a/manifests/compute/libvirt/qemu.pp b/manifests/compute/libvirt/qemu.pp index cb73eeb2e..06a906565 100644 --- a/manifests/compute/libvirt/qemu.pp +++ b/manifests/compute/libvirt/qemu.pp @@ -8,6 +8,10 @@ # (optional) Whether or not configure qemu bits. # Defaults to false. # +# [*group*] +# (optional) Group under which the qemu should run. +# Defaults to undef. +# # [*max_files*] # (optional) Maximum number of opened files, per process. # Defaults to 1024. @@ -18,6 +22,7 @@ # class nova::compute::libvirt::qemu( $configure_qemu = false, + $group = undef, $max_files = 1024, $max_processes = 4096, ){ @@ -34,12 +39,20 @@ class nova::compute::libvirt::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': context => '/files/etc/libvirt/qemu.conf', - changes => [ - "set max_files ${max_files}", - "set max_processes ${max_processes}", - ], + changes => $augues_changes, tag => 'qemu-conf-augeas', } } else { @@ -48,6 +61,7 @@ class nova::compute::libvirt::qemu( changes => [ 'rm max_files', 'rm max_processes', + 'rm group', ], tag => 'qemu-conf-augeas', } diff --git a/releasenotes/notes/libvirt-qemu-group-8430caa099147529.yaml b/releasenotes/notes/libvirt-qemu-group-8430caa099147529.yaml new file mode 100644 index 000000000..f2ee45d69 --- /dev/null +++ b/releasenotes/notes/libvirt-qemu-group-8430caa099147529.yaml @@ -0,0 +1,3 @@ +--- +features: + - Added group parameter to configure qemu.conf diff --git a/spec/classes/nova_compute_libvirt_qemu_spec.rb b/spec/classes/nova_compute_libvirt_qemu_spec.rb index f48ee03da..6a452533e 100644 --- a/spec/classes/nova_compute_libvirt_qemu_spec.rb +++ b/spec/classes/nova_compute_libvirt_qemu_spec.rb @@ -18,7 +18,7 @@ describe 'nova::compute::libvirt::qemu' do end it { is_expected.to contain_augeas('qemu-conf-limits').with({ :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]') } end @@ -49,6 +49,26 @@ describe 'nova::compute::libvirt::qemu' do :tag => 'qemu-conf-augeas', }).that_notifies('Service[libvirt]') } 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 on_supported_os({