From dcda81db3eb61bdf69751ce6963b564abf7b7e0c Mon Sep 17 00:00:00 2001 From: Feng Pan Date: Sun, 17 Sep 2017 22:47:51 -0400 Subject: Add vhost-user configurations This patch adds capability for configuring the following options in vhost-user section: - coalesce-frames - coalesce-time - dont-dump-memory JIRA: PUP-8 Change-Id: I906e7d3c937d2f1133e2bfc0838c16063b535b87 Signed-off-by: Feng Pan --- lib/puppet/provider/vpp_config/vpp.rb | 2 +- lib/puppet/type/vpp_config.rb | 2 +- manifests/config.pp | 8 ++++++++ manifests/init.pp | 36 ++++++++++++++++++++++++++--------- manifests/params.pp | 3 +++ spec/acceptance/fdio_spec.rb | 9 +++++++-- spec/classes/fdio_spec.rb | 15 +++++++++++++++ 7 files changed, 62 insertions(+), 13 deletions(-) diff --git a/lib/puppet/provider/vpp_config/vpp.rb b/lib/puppet/provider/vpp_config/vpp.rb index eb49fe3..767e96d 100644 --- a/lib/puppet/provider/vpp_config/vpp.rb +++ b/lib/puppet/provider/vpp_config/vpp.rb @@ -16,7 +16,7 @@ Puppet::Type.type(:vpp_config).provide(:vpp) do end if @dev - @search_regex = /^\s*dev\s+#{@dev}\s*({[^}]*})?/ + @search_regex = /^\s*dev\s+#{@dev}\s*{([^}]*)}?/ else @search_regex = /^\s*#{@real_setting}\s+(\S+)?/ end diff --git a/lib/puppet/type/vpp_config.rb b/lib/puppet/type/vpp_config.rb index 17c910f..bfb511b 100644 --- a/lib/puppet/type/vpp_config.rb +++ b/lib/puppet/type/vpp_config.rb @@ -7,7 +7,7 @@ Puppet::Type.newtype(:vpp_config) do newproperty(:value) do munge do |value| - value.strip if value.is_a? String + value.to_s.strip end end diff --git a/manifests/config.pp b/manifests/config.pp index d3773b7..2a99ea2 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -17,6 +17,14 @@ class fdio::config { 'dpdk/dev/default': value => $fdio::vpp_dpdk_dev_default_options; 'dpdk/uio-driver': value => $fdio::vpp_dpdk_uio_driver; 'dpdk/socket-mem': value => $fdio::vpp_dpdk_socket_mem; + 'vhost-user/coalesce-frames': value => $fdio::vpp_vhostuser_coalesce_frames; + 'vhost-user/coalesce-time': value => $fdio::vpp_vhostuser_coalesce_time; + } + + if $fdio::vpp_vhostuser_dont_dump_memory { + vpp_config { + 'vhost-user/dont-dump-memory': ensure => present; + } } fdio::config::vpp_devices { $fdio::vpp_dpdk_devs: } diff --git a/manifests/init.pp b/manifests/init.pp index 8e0b9bf..eda67f7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,20 +42,38 @@ # Example: '2,3'. # Defaults to undef (no pinning) # +# [*vpp_vhostuser_coalesce_frames*] +# (optional) vhost-user coalesce frames. +# Example: 32 +# Defaults to undef +# +# [*vpp_vhostuser_coalesce_time*] +# (optional) vhost-user coalesce time in seconds +# Example: 0.005 +# Defaults to undef +# +# [*vpp_vhostuser_dont_dump_memory*] +# (optional) vhost-user dont-dump-memory option. Avoids dumping vhost-user +# shared memory segments to core files. +# Defaults to false +# # [*copy_kernel_nic_ip*] # (optional) Configures VPP interface with IP settings found on its corresponding kernel NIC. # Defaults to true # class fdio ( - $repo_branch = $::fdio::params::repo_branch, - $vpp_dpdk_support = $::fdio::params::vpp_dpdk_support, - $vpp_dpdk_devs = $::fdio::params::vpp_dpdk_devs, - $vpp_dpdk_uio_driver = $::fdio::params::vpp_dpdk_uio_driver, - $vpp_dpdk_dev_default_options = $::fdio::params::vpp_dpdk_dev_default_options, - $vpp_dpdk_socket_mem = $::fdio::params::vpp_dpdk_socket_mem, - $vpp_cpu_main_core = $::fdio::params::vpp_cpu_main_core, - $vpp_cpu_corelist_workers = $::fdio::params::vpp_cpu_corelist_workers, - $copy_kernel_nic_ip = $::fdio::params::copy_kernel_nic_ip, + $repo_branch = $::fdio::params::repo_branch, + $vpp_dpdk_support = $::fdio::params::vpp_dpdk_support, + $vpp_dpdk_devs = $::fdio::params::vpp_dpdk_devs, + $vpp_dpdk_uio_driver = $::fdio::params::vpp_dpdk_uio_driver, + $vpp_dpdk_dev_default_options = $::fdio::params::vpp_dpdk_dev_default_options, + $vpp_dpdk_socket_mem = $::fdio::params::vpp_dpdk_socket_mem, + $vpp_cpu_main_core = $::fdio::params::vpp_cpu_main_core, + $vpp_cpu_corelist_workers = $::fdio::params::vpp_cpu_corelist_workers, + $vpp_vhostuser_coalesce_frames = $::fdio::params::vpp_vhostuser_coalesce_frames, + $vpp_vhostuser_coalesce_time = $::fdio::params::vpp_vhostuser_coalesce_time, + $vpp_vhostuser_dont_dump_memory = $::fdio::params::vpp_vhostuser_dont_dump_memory, + $copy_kernel_nic_ip = $::fdio::params::copy_kernel_nic_ip, ) inherits ::fdio::params { validate_array($vpp_dpdk_devs) diff --git a/manifests/params.pp b/manifests/params.pp index 796b198..8859667 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -11,5 +11,8 @@ class fdio::params { $vpp_dpdk_socket_mem = undef $vpp_cpu_main_core = undef $vpp_cpu_corelist_workers = undef + $vpp_vhostuser_coalesce_frames = undef + $vpp_vhostuser_coalesce_time = undef + $vpp_vhostuser_dont_dump_memory = false $copy_kernel_nic_ip = true } diff --git a/spec/acceptance/fdio_spec.rb b/spec/acceptance/fdio_spec.rb index 18e54b0..68f2013 100644 --- a/spec/acceptance/fdio_spec.rb +++ b/spec/acceptance/fdio_spec.rb @@ -31,13 +31,16 @@ describe 'fdio' do end - context 'pinning' do + context 'with options' do it 'should work with no errors' do pp= <<-EOS class { '::fdio': repo_branch => 'stable.1707', vpp_cpu_main_core => '1', vpp_cpu_corelist_workers => '2', + vpp_vhostuser_coalesce_frames => 32, + vpp_vhostuser_coalesce_time => 0.05, + vpp_vhostuser_dont_dump_memory => true, } EOS @@ -48,7 +51,9 @@ describe 'fdio' do describe file('/etc/vpp/startup.conf') do its(:content) { should match /main-core\s+1/ } its(:content) { should match /corelist-workers\s+2/ } + its(:content) { should match /coalesce-frames\s+32/ } + its(:content) { should match /coalesce-time\s+0.05/ } + its(:content) { should match /dont-dump-memory/ } end - end end diff --git a/spec/classes/fdio_spec.rb b/spec/classes/fdio_spec.rb index 8f0a088..4786ac0 100644 --- a/spec/classes/fdio_spec.rb +++ b/spec/classes/fdio_spec.rb @@ -71,6 +71,21 @@ describe 'fdio' do is_expected.to contain_vpp_config('dpdk/socket-mem').with_value('1024,1024') end end + + context 'with vhost-user' do + before :each do + params.merge!( + :vpp_vhostuser_coalesce_frames => 32, + :vpp_vhostuser_coalesce_time => 0.05, + :vpp_vhostuser_dont_dump_memory => true + ) + end + it 'should configure vhost-user options' do + is_expected.to contain_vpp_config('vhost-user/coalesce-frames').with_value('32') + is_expected.to contain_vpp_config('vhost-user/coalesce-time').with_value('0.05') + is_expected.to contain_vpp_config('vhost-user/dont-dump-memory').with_ensure('present') + end + end end shared_examples_for 'fdio - service' do -- cgit 1.2.3-korg