Allow specification of domain shares (#925)

Weighted priority of the domain relative to others on the host.
This commit is contained in:
Quinten Johnson
2020-05-10 05:24:06 -05:00
committed by GitHub
parent d9c5f63410
commit 618c8b251d
6 changed files with 17 additions and 0 deletions

View File

@@ -295,6 +295,7 @@ end
you create a domain value by default virtio KVM believe possible values, see
the [documentation for
Libvirt](https://libvirt.org/formatdomain.html#elementsNICSModel).
* `shares` - Proportional weighted share for the domain relative to others. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsCPUTuning).
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
* `cpus` - Number of virtual cpus. Defaults to 1 if not set.
* `cpuset` - Physical cpus to which the vcpus can be pinned. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsCPUAllocation).

View File

@@ -39,6 +39,7 @@ module VagrantPlugins
@nodeset = config.nodeset
@features = config.features
@features_hyperv = config.features_hyperv
@shares = config.shares
@cpu_mode = config.cpu_mode
@cpu_model = config.cpu_model
@cpu_fallback = config.cpu_fallback
@@ -213,6 +214,9 @@ module VagrantPlugins
@memory_backing.each do |backing|
env[:ui].info(" -- Memory Backing: #{backing[:name]}: #{backing[:config].map { |k,v| "#{k}='#{v}'"}.join(' ')}")
end
unless @shares.nil?
env[:ui].info(" -- Shares: #{@shares}")
end
env[:ui].info(" -- Management MAC: #{@management_network_mac}")
env[:ui].info(" -- Loader: #{@loader}")
env[:ui].info(" -- Nvram: #{@nvram}")

View File

@@ -79,6 +79,7 @@ module VagrantPlugins
attr_accessor :cpu_fallback
attr_accessor :cpu_features
attr_accessor :cpu_topology
attr_accessor :shares
attr_accessor :features
attr_accessor :features_hyperv
attr_accessor :numa_nodes
@@ -204,6 +205,7 @@ module VagrantPlugins
@cpu_fallback = UNSET_VALUE
@cpu_features = UNSET_VALUE
@cpu_topology = UNSET_VALUE
@shares = UNSET_VALUE
@features = UNSET_VALUE
@features_hyperv = UNSET_VALUE
@numa_nodes = UNSET_VALUE
@@ -689,6 +691,7 @@ module VagrantPlugins
@cpu_topology = {} if @cpu_topology == UNSET_VALUE
@cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE
@cpu_features = [] if @cpu_features == UNSET_VALUE
@shares = nil if @shares == UNSET_VALUE
@features = ['acpi','apic','pae'] if @features == UNSET_VALUE
@features_hyperv = [] if @features_hyperv == UNSET_VALUE
@numa_nodes = @numa_nodes == UNSET_VALUE ? nil : _generate_numa

View File

@@ -45,6 +45,11 @@
<% end %>
</memoryBacking>
<% end%>
<% if @shares %>
<cputune>
<shares><%= @shares %></shares>
</cputune>
<% end %>
<os>
<% if @machine_type %>

View File

@@ -14,6 +14,9 @@
<numatune>
<memory nodeset='1-4,^3,6'/>
</numatune>
<cputune>
<shares>1024</shares>
</cputune>
<os>
<type arch='x86_64' machine='pc-compatible'>hvm</type>

View File

@@ -76,6 +76,7 @@ describe 'templates/domain' do
domain.qemuargs(value: '-device')
domain.qemuargs(value: 'dummy-device')
domain.shares = '1024'
domain.cpuset = '1-4,^3,6'
domain.nodeset = '1-4,^3,6'
end