Merge branch 'master' into pci_network

This commit is contained in:
Dmitry Vasilets 2018-02-02 17:48:00 +01:00 committed by GitHub
commit 3b91515bd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 0 deletions

View File

@ -282,6 +282,17 @@ end
libvirt](https://libvirt.org/formatdomain.html#elementsNICSModel). libvirt](https://libvirt.org/formatdomain.html#elementsNICSModel).
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set. * `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
* `cpus` - Number of virtual cpus. Defaults to 1 if not set. * `cpus` - Number of virtual cpus. Defaults to 1 if not set.
* `cputopology` - Number of CPU sockets, cores and threads running per core. All fields of `:sockets`, `:cores` and `:threads` are mandatory, `cpus` domain option must be present and must be equal to total count of **sockets * cores * threads**. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsCPU).
```ruby
Vagrant.configure("2") do |config|
config.vm.provider :libvirt do |libvirt|
libvirt.cpus = 4
libvirt.cputopology :sockets => '2', :cores => '2', :threads => '1'
end
end
```
* `nested` - [Enable nested * `nested` - [Enable nested
virtualization](https://github.com/torvalds/linux/blob/master/Documentation/virtual/kvm/nested-vmx.txt). virtualization](https://github.com/torvalds/linux/blob/master/Documentation/virtual/kvm/nested-vmx.txt).
Default is false. Default is false.
@ -691,6 +702,7 @@ used by this network are configurable at the provider level.
specified the default is 'false'. specified the default is 'false'.
* `:management_network_pci_bus` - The bus of the PCI device. * `:management_network_pci_bus` - The bus of the PCI device.
* `:management_network_pci_slot` - The slot of the PCI device. * `:management_network_pci_slot` - The slot of the PCI device.
* `management_network_mac` - MAC address of management network interface.
You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt
doesn't provide a standard way to find out the IP address of a running domain. doesn't provide a standard way to find out the IP address of a running domain.

View File

@ -34,6 +34,7 @@ module VagrantPlugins
@uuid = config.uuid @uuid = config.uuid
@cpus = config.cpus.to_i @cpus = config.cpus.to_i
@cpu_features = config.cpu_features @cpu_features = config.cpu_features
@cpu_topology = config.cpu_topology
@features = config.features @features = config.features
@cpu_mode = config.cpu_mode @cpu_mode = config.cpu_mode
@cpu_model = config.cpu_model @cpu_model = config.cpu_model
@ -176,6 +177,10 @@ module VagrantPlugins
env[:ui].info(" -- Forced UUID: #{@uuid}") if @uuid != '' env[:ui].info(" -- Forced UUID: #{@uuid}") if @uuid != ''
env[:ui].info(" -- Domain type: #{@domain_type}") env[:ui].info(" -- Domain type: #{@domain_type}")
env[:ui].info(" -- Cpus: #{@cpus}") env[:ui].info(" -- Cpus: #{@cpus}")
if not @cpu_topology.empty?
env[:ui].info(" -- CPU topology: sockets=#{@cpu_topology[:sockets]}, cores=#{@cpu_topology[:cores]}, threads=#{@cpu_topology[:threads]}")
end
env[:ui].info("")
@cpu_features.each do |cpu_feature| @cpu_features.each do |cpu_feature|
env[:ui].info(" -- CPU Feature: name=#{cpu_feature[:name]}, policy=#{cpu_feature[:policy]}") env[:ui].info(" -- CPU Feature: name=#{cpu_feature[:name]}, policy=#{cpu_feature[:policy]}")
end end

View File

@ -47,6 +47,11 @@ module VagrantPlugins
message_attributes message_attributes
)) ))
if fp[:protocol] == 'udp'
env[:ui].warn I18n.t('vagrant_libvirt.warnings.forwarding_udp')
next
end
ssh_pid = redirect_port( ssh_pid = redirect_port(
@env[:machine], @env[:machine],
fp[:host_ip] || 'localhost', fp[:host_ip] || 'localhost',
@ -95,6 +100,7 @@ module VagrantPlugins
StrictHostKeyChecking=no StrictHostKeyChecking=no
PasswordAuthentication=no PasswordAuthentication=no
ForwardX11=#{ssh_info[:forward_x11] ? 'yes' : 'no'} ForwardX11=#{ssh_info[:forward_x11] ? 'yes' : 'no'}
IdentitiesOnly=#{ssh_info[:keys_only] ? 'yes' : 'no'}
) + ssh_info[:private_key_path].map do |pk| ) + ssh_info[:private_key_path].map do |pk|
"IdentityFile='\"#{pk}\"'" "IdentityFile='\"#{pk}\"'"
end).map { |s| s.prepend('-o ') }.join(' ') end).map { |s| s.prepend('-o ') }.join(' ')

View File

@ -67,6 +67,7 @@ module VagrantPlugins
attr_accessor :cpu_model attr_accessor :cpu_model
attr_accessor :cpu_fallback attr_accessor :cpu_fallback
attr_accessor :cpu_features attr_accessor :cpu_features
attr_accessor :cpu_topology
attr_accessor :features attr_accessor :features
attr_accessor :numa_nodes attr_accessor :numa_nodes
attr_accessor :loader attr_accessor :loader
@ -175,6 +176,7 @@ module VagrantPlugins
@cpu_model = UNSET_VALUE @cpu_model = UNSET_VALUE
@cpu_fallback = UNSET_VALUE @cpu_fallback = UNSET_VALUE
@cpu_features = UNSET_VALUE @cpu_features = UNSET_VALUE
@cpu_topology = UNSET_VALUE
@features = UNSET_VALUE @features = UNSET_VALUE
@numa_nodes = UNSET_VALUE @numa_nodes = UNSET_VALUE
@loader = UNSET_VALUE @loader = UNSET_VALUE
@ -319,6 +321,20 @@ module VagrantPlugins
policy: options[:policy]) policy: options[:policy])
end end
def cputopology(options = {})
if options[:sockets].nil? || options[:cores].nil? || options[:threads].nil?
raise 'CPU topology must have all of sockets, cores and threads specified'
end
if @cpu_topology == UNSET_VALUE
@cpu_topology = {}
end
@cpu_topology[:sockets] = options[:sockets]
@cpu_topology[:cores] = options[:cores]
@cpu_topology[:threads] = options[:threads]
end
def memorybacking(option, config = {}) def memorybacking(option, config = {})
case option case option
when :source when :source
@ -600,6 +616,7 @@ module VagrantPlugins
elsif @cpu_mode != 'custom' elsif @cpu_mode != 'custom'
'' ''
end end
@cpu_topology = {} if @cpu_topology == UNSET_VALUE
@cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE @cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE
@cpu_features = [] if @cpu_features == UNSET_VALUE @cpu_features = [] if @cpu_features == UNSET_VALUE
@features = ['acpi','apic','pae'] if @features == UNSET_VALUE @features = ['acpi','apic','pae'] if @features == UNSET_VALUE

View File

@ -15,6 +15,10 @@
<% @cpu_features.each do |cpu_feature| %> <% @cpu_features.each do |cpu_feature| %>
<feature name='<%= cpu_feature[:name] %>' policy='<%= cpu_feature[:policy] %>'/> <feature name='<%= cpu_feature[:name] %>' policy='<%= cpu_feature[:policy] %>'/>
<% end %> <% end %>
<% unless @cpu_topology.empty? %>
<%# CPU topology -%>
<topology sockets='<%= @cpu_topology[:sockets] %>' cores='<%= @cpu_topology[:cores] %>' threads='<%= @cpu_topology[:threads] %>'/>
<% end %>
<% end %> <% end %>
<% if @numa_nodes %> <% if @numa_nodes %>
<numa> <numa>

View File

@ -54,6 +54,8 @@ en:
ignoring_virtual_size_too_small: |- ignoring_virtual_size_too_small: |-
Ignoring requested virtual disk size of '%{requested}' as it is below Ignoring requested virtual disk size of '%{requested}' as it is below
the minimum box image size of '%{minimum}'. the minimum box image size of '%{minimum}'.
forwarding_udp: |-
Forwarding UDP ports is not supported. Ignoring.
errors: errors:
package_not_supported: No support for package with libvirt. Create box manually. package_not_supported: No support for package with libvirt. Create box manually.

View File

@ -8,6 +8,7 @@
<cpu mode='custom'> <cpu mode='custom'>
<model fallback='allow'>qemu64</model> <model fallback='allow'>qemu64</model>
<feature name='AAA' policy='required'/> <feature name='AAA' policy='required'/>
<topology sockets='1' cores='3' threads='2'/>
</cpu> </cpu>

View File

@ -31,6 +31,7 @@ describe 'templates/domain' do
domain.instance_variable_set('@domain_type', 'kvm') domain.instance_variable_set('@domain_type', 'kvm')
domain.cpu_mode = 'custom' domain.cpu_mode = 'custom'
domain.cpu_feature(name: 'AAA', policy: 'required') domain.cpu_feature(name: 'AAA', policy: 'required')
domain.cputopology(sockets: '1', cores: '3', threads: '2')
domain.machine_type = 'pc-compatible' domain.machine_type = 'pc-compatible'
domain.machine_arch = 'x86_64' domain.machine_arch = 'x86_64'
domain.loader = '/efi/loader' domain.loader = '/efi/loader'