Specify PCI bus and slot for net iface

Signed-off-by: Tomasz Madycki <tomasz.madycki@gmail.com>
This commit is contained in:
Tomasz Madycki
2018-01-24 18:08:59 +01:00
parent 6fdbf4b818
commit c01ddb8dd4
3 changed files with 12 additions and 2 deletions

View File

@@ -639,6 +639,8 @@ starts with `libvirt__` string. Here is a list of those options:
info](http://www.linux-kvm.org/page/Multiqueue) info](http://www.linux-kvm.org/page/Multiqueue)
* `:autostart` - Automatic startup of network by the libvirt daemon. * `:autostart` - Automatic startup of network by the libvirt daemon.
If not specified the default is 'false'. If not specified the default is 'false'.
* `:bus` - The bus of the PCI device. Both :bus and :slot have to be defined.
* `:slot` - The slot of the PCI device. Both :bus and :slot have to be defined.
When the option `:libvirt__dhcp_enabled` is to to 'false' it shouldn't matter When the option `:libvirt__dhcp_enabled` is to to 'false' it shouldn't matter
whether the virtual network contains a DHCP server or not and vagrant-libvirt whether the virtual network contains a DHCP server or not and vagrant-libvirt

View File

@@ -77,6 +77,8 @@ module VagrantPlugins
@driver_queues = iface_configuration.fetch(:driver_queues, false) @driver_queues = iface_configuration.fetch(:driver_queues, false)
@device_name = iface_configuration.fetch(:iface_name, false) @device_name = iface_configuration.fetch(:iface_name, false)
@mtu = iface_configuration.fetch(:mtu, nil) @mtu = iface_configuration.fetch(:mtu, nil)
@pci_bus = iface_configuration.fetch(:bus, nil)
@pci_slot = iface_configuration.fetch(:slot, nil)
template_name = 'interface' template_name = 'interface'
# Configuration for public interfaces which use the macvtap driver # Configuration for public interfaces which use the macvtap driver
if iface_configuration[:iface_type] == :public_network if iface_configuration[:iface_type] == :public_network
@@ -146,7 +148,9 @@ module VagrantPlugins
@model_type, @model_type,
@mtu, @mtu,
driver_options, driver_options,
@udp_tunnel) @udp_tunnel,
@pci_bus,
@pci_slot)
else else
to_xml(template_name) to_xml(template_name)
end end
@@ -237,7 +241,7 @@ module VagrantPlugins
def interface_xml(type, source_options, mac, device_name, def interface_xml(type, source_options, mac, device_name,
iface_number, model_type, mtu, driver_options, iface_number, model_type, mtu, driver_options,
udp_tunnel={}) udp_tunnel={}, pci_bus, pci_slot)
Nokogiri::XML::Builder.new do |xml| Nokogiri::XML::Builder.new do |xml|
xml.interface(type: type || 'network') do xml.interface(type: type || 'network') do
xml.source(source_options) do xml.source(source_options) do
@@ -249,6 +253,7 @@ module VagrantPlugins
xml.model(type: model_type.to_s) xml.model(type: model_type.to_s)
xml.mtu(size: Integer(mtu)) if mtu xml.mtu(size: Integer(mtu)) if mtu
xml.driver(driver_options) xml.driver(driver_options)
xml.address(type: 'pci', bus: pci_bus, slot: pci_slot) if pci_bus and pci_slot
end end
end.to_xml( end.to_xml(
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION | save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |

View File

@@ -20,4 +20,7 @@
<% if @ovs %> <% if @ovs %>
<virtualport type='openvswitch'/> <virtualport type='openvswitch'/>
<% end %> <% end %>
<% if @pci_bus and @pci_slot %>
<address type='pci' bus='<%=@pci_bus%>' slot='<%=@pci_slot%>' />
<% end %>
</interface> </interface>