From c01ddb8dd43b46f9469bcb41643255bef4b2974b Mon Sep 17 00:00:00 2001 From: Tomasz Madycki Date: Wed, 24 Jan 2018 18:08:59 +0100 Subject: [PATCH] Specify PCI bus and slot for net iface Signed-off-by: Tomasz Madycki --- README.md | 2 ++ lib/vagrant-libvirt/action/create_network_interfaces.rb | 9 +++++++-- lib/vagrant-libvirt/templates/public_interface.xml.erb | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fce6f0e..938fe32 100644 --- a/README.md +++ b/README.md @@ -639,6 +639,8 @@ starts with `libvirt__` string. Here is a list of those options: info](http://www.linux-kvm.org/page/Multiqueue) * `:autostart` - Automatic startup of network by the libvirt daemon. 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 whether the virtual network contains a DHCP server or not and vagrant-libvirt diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb index 00293e5..9304f2c 100644 --- a/lib/vagrant-libvirt/action/create_network_interfaces.rb +++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb @@ -77,6 +77,8 @@ module VagrantPlugins @driver_queues = iface_configuration.fetch(:driver_queues, false) @device_name = iface_configuration.fetch(:iface_name, false) @mtu = iface_configuration.fetch(:mtu, nil) + @pci_bus = iface_configuration.fetch(:bus, nil) + @pci_slot = iface_configuration.fetch(:slot, nil) template_name = 'interface' # Configuration for public interfaces which use the macvtap driver if iface_configuration[:iface_type] == :public_network @@ -146,7 +148,9 @@ module VagrantPlugins @model_type, @mtu, driver_options, - @udp_tunnel) + @udp_tunnel, + @pci_bus, + @pci_slot) else to_xml(template_name) end @@ -237,7 +241,7 @@ module VagrantPlugins def interface_xml(type, source_options, mac, device_name, iface_number, model_type, mtu, driver_options, - udp_tunnel={}) + udp_tunnel={}, pci_bus, pci_slot) Nokogiri::XML::Builder.new do |xml| xml.interface(type: type || 'network') do xml.source(source_options) do @@ -249,6 +253,7 @@ module VagrantPlugins xml.model(type: model_type.to_s) xml.mtu(size: Integer(mtu)) if mtu xml.driver(driver_options) + xml.address(type: 'pci', bus: pci_bus, slot: pci_slot) if pci_bus and pci_slot end end.to_xml( save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION | diff --git a/lib/vagrant-libvirt/templates/public_interface.xml.erb b/lib/vagrant-libvirt/templates/public_interface.xml.erb index 75e8628..da541db 100644 --- a/lib/vagrant-libvirt/templates/public_interface.xml.erb +++ b/lib/vagrant-libvirt/templates/public_interface.xml.erb @@ -20,4 +20,7 @@ <% if @ovs %> <% end %> + <% if @pci_bus and @pci_slot %> +
+ <% end %>