mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Merge pull request #853 from tmad/pci_network
Add option to specify PCI bus/slot for network interfaces
This commit is contained in:
commit
d9732b855f
@ -650,6 +650,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
|
||||
@ -698,6 +700,8 @@ used by this network are configurable at the provider level.
|
||||
for for more information.
|
||||
* `management_network_autostart` - Automatic startup of mgmt network, if not
|
||||
specified the default is 'false'.
|
||||
* `:management_network_pci_bus` - The bus 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
|
||||
|
@ -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 |
|
||||
|
@ -51,6 +51,8 @@ module VagrantPlugins
|
||||
attr_accessor :management_network_mac
|
||||
attr_accessor :management_network_guest_ipv6
|
||||
attr_accessor :management_network_autostart
|
||||
attr_accessor :management_network_pci_bus
|
||||
attr_accessor :management_network_pci_slot
|
||||
|
||||
# Default host prefix (alternative to use project folder name)
|
||||
attr_accessor :default_prefix
|
||||
@ -162,6 +164,8 @@ module VagrantPlugins
|
||||
@management_network_mac = UNSET_VALUE
|
||||
@management_network_guest_ipv6 = UNSET_VALUE
|
||||
@management_network_autostart = UNSET_VALUE
|
||||
@management_network_pci_slot = UNSET_VALUE
|
||||
@management_network_pci_bus = UNSET_VALUE
|
||||
|
||||
# Domain specific settings.
|
||||
@uuid = UNSET_VALUE
|
||||
@ -595,6 +599,8 @@ module VagrantPlugins
|
||||
@management_network_mac = nil if @management_network_mac == UNSET_VALUE
|
||||
@management_network_guest_ipv6 = 'yes' if @management_network_guest_ipv6 == UNSET_VALUE
|
||||
@management_network_autostart = false if @management_network_autostart == UNSET_VALUE
|
||||
@management_network_pci_bus = nil if @management_network_pci_bus == UNSET_VALUE
|
||||
@management_network_pci_slot = nil if @management_network_pci_slot == UNSET_VALUE
|
||||
|
||||
# generate a URI if none is supplied
|
||||
@uri = _generate_uri if @uri == UNSET_VALUE
|
||||
|
@ -20,4 +20,7 @@
|
||||
<% if @ovs %>
|
||||
<virtualport type='openvswitch'/>
|
||||
<% end %>
|
||||
<% if @pci_bus and @pci_slot %>
|
||||
<address type='pci' bus='<%=@pci_bus%>' slot='<%=@pci_slot%>' />
|
||||
<% end %>
|
||||
</interface>
|
||||
|
@ -14,6 +14,8 @@ module VagrantPlugins
|
||||
management_network_mac = env[:machine].provider_config.management_network_mac
|
||||
management_network_guest_ipv6 = env[:machine].provider_config.management_network_guest_ipv6
|
||||
management_network_autostart = env[:machine].provider_config.management_network_autostart
|
||||
management_network_pci_bus = env[:machine].provider_config.management_network_pci_bus
|
||||
management_network_pci_slot = env[:machine].provider_config.management_network_pci_slot
|
||||
logger.info "Using #{management_network_name} at #{management_network_address} as the management network #{management_network_mode} is the mode"
|
||||
|
||||
begin
|
||||
@ -39,13 +41,20 @@ module VagrantPlugins
|
||||
dhcp_enabled: true,
|
||||
forward_mode: management_network_mode,
|
||||
guest_ipv6: management_network_guest_ipv6,
|
||||
autostart: management_network_autostart
|
||||
autostart: management_network_autostart,
|
||||
bus: management_network_pci_bus,
|
||||
slot: management_network_pci_slot
|
||||
}
|
||||
|
||||
unless management_network_mac.nil?
|
||||
management_network_options[:mac] = management_network_mac
|
||||
end
|
||||
|
||||
unless management_network_pci_bus.nil? and management_network_pci_slot.nil?
|
||||
management_network_options[:bus] = management_network_pci_bus
|
||||
management_network_options[:slot] = management_network_pci_slot
|
||||
end
|
||||
|
||||
if (env[:machine].config.vm.box &&
|
||||
!env[:machine].provider_config.mgmt_attach)
|
||||
raise Errors::ManagementNetworkRequired
|
||||
|
Loading…
Reference in New Issue
Block a user