refactored and fixed numa_nodes domain specific option

This commit is contained in:
Homero Pawlowski 2017-08-02 01:07:23 -04:00
parent 6929c7a9b6
commit f11abb8b74
4 changed files with 27 additions and 37 deletions

View File

@ -300,7 +300,15 @@ end
* `cpu_fallback` - Whether to allow libvirt to fall back to a CPU model close
to the specified model if features in the guest CPU are not supported on the
host. Defaults to 'allow' if not set. Allowed values: `allow`, `forbid`.
* `numa_nodes` - Number of NUMA nodes on guest. Must be a factor of `cpu`.
* `numa_nodes` - Specify an array of NUMA nodes for the guest. The syntax is similar to what would be set in the domain XML. `memory` must be in MB. Symmetrical and asymmetrical topologies are supported but ake sure your total count of defined CPUs adds up to v.cpus.
The sum of all the memory defined here will act as your total memory for your guest VM. **This sum will override what is set in `v.memory`**
```
v.numa_nodes = [
{:id => 0, :cpus => "0-1", :memory => "1024"},
{:id => 1, :cpus => "2-3", :memory => "4096"}
]
```
* `loader` - Sets path to custom UEFI loader.
* `volume_cache` - Controls the cache mechanism. Possible values are "default",
"none", "writethrough", "writeback", "directsync" and "unsafe". [See

View File

@ -23,9 +23,13 @@ module VagrantPlugins
libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
if config.memory.to_i * 1024 != libvirt_domain.max_memory
libvirt_domain.max_memory = config.memory.to_i * 1024
libvirt_domain.memory = libvirt_domain.max_memory
# libvirt API doesn't support modifying memory on NUMA enabled CPUs
# http://libvirt.org/git/?p=libvirt.git;a=commit;h=d174394105cf00ed266bf729ddf461c21637c736
if config.numa_nodes == nil
if config.memory.to_i * 1024 != libvirt_domain.max_memory
libvirt_domain.max_memory = config.memory.to_i * 1024
libvirt_domain.memory = libvirt_domain.max_memory
end
end
begin
# XML definition manipulation
@ -124,13 +128,6 @@ module VagrantPlugins
cpu.delete_element(svm_feature)
end
end
else
unless cpu.elements.to_a.empty?
descr_changed = true
cpu.elements.each do |elem|
cpu.delete_element(elem)
end
end
end
# Graphics

View File

@ -279,26 +279,12 @@ module VagrantPlugins
end
def _generate_numa
raise 'NUMA nodes must be a factor of CPUs' if @cpus % @numa_nodes != 0
# todo: compare count of NUMA defined CPUs and throw warning
# if config.cpu != NUMA.cpu
if @memory % @numa_nodes != 0
raise 'NUMA nodes must be a factor of memory'
end
@numa_nodes.collect { |x| x[:memory] = x[:memory].to_i * 1024 }
numa = []
(1..@numa_nodes).each do |node|
numa_cpu_start = (@cpus / @numa_nodes) * (node - 1)
numa_cpu_end = (@cpus / @numa_nodes) * node - 1
numa_cpu = Array(numa_cpu_start..numa_cpu_end).join(',')
numa_mem = @memory / @numa_nodes
numa.push(id: node,
cpu: numa_cpu,
mem: numa_mem)
end
@numa_nodes = numa
@numa_nodes
end
def cpu_feature(options = {})

View File

@ -15,14 +15,13 @@
<% @cpu_features.each do |cpu_feature| %>
<feature name='<%= cpu_feature[:name] %>' policy='<%= cpu_feature[:policy] %>'/>
<% end %>
<% else %>
<% if @numa_nodes %>
<numa>
<% @numa_nodes.each do |node| %>
<cell id='<%= node[:id] %>' cpus='<%= node[:cpu] %>' memory='<%= node[:mem] %>'/>
<% end %>
</numa>
<% end %>
<% end %>
<% if @numa_nodes %>
<numa>
<% @numa_nodes.each do |node| %>
<cell id='<%= node[:id] %>' cpus='<%= node[:cpus] %>' memory='<%= node[:memory] %>'/>
<% end %>
</numa>
<% end %>
</cpu>