mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Add mtu option for private networks and interfaces
In order to create virtual networks with different MTU sizes than the libvirt default of 1500, this patch adds a libvirt__mtu option. This will add an mtu option to the libvirt network definition and to the domain interface definition as well.
This commit is contained in:
@@ -626,6 +626,9 @@ starts with `libvirt__` string. Here is a list of those options:
|
|||||||
failures](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/498)
|
failures](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/498)
|
||||||
* `:mac` - MAC address for the interface. *Note: specify this in lowercase
|
* `:mac` - MAC address for the interface. *Note: specify this in lowercase
|
||||||
since Vagrant network scripts assume it will be!*
|
since Vagrant network scripts assume it will be!*
|
||||||
|
* `:libvirt__mtu` - MTU size for the libvirt network, if not defined, the
|
||||||
|
created network will use the libvirt default (1500). VMs still need to set the
|
||||||
|
MTU accordingly.
|
||||||
* `:model_type` - parameter specifies the model of the network adapter when you
|
* `:model_type` - parameter specifies the model of the network adapter when you
|
||||||
create a domain value by default virtio KVM believe possible values, see the
|
create a domain value by default virtio KVM believe possible values, see the
|
||||||
documentation for libvirt
|
documentation for libvirt
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ module VagrantPlugins
|
|||||||
@driver_name = iface_configuration.fetch(:driver_name, false)
|
@driver_name = iface_configuration.fetch(:driver_name, false)
|
||||||
@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)
|
||||||
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
|
||||||
@@ -143,6 +144,7 @@ module VagrantPlugins
|
|||||||
@device_name,
|
@device_name,
|
||||||
@iface_number,
|
@iface_number,
|
||||||
@model_type,
|
@model_type,
|
||||||
|
@mtu,
|
||||||
driver_options,
|
driver_options,
|
||||||
@udp_tunnel)
|
@udp_tunnel)
|
||||||
else
|
else
|
||||||
@@ -234,7 +236,7 @@ module VagrantPlugins
|
|||||||
end
|
end
|
||||||
|
|
||||||
def interface_xml(type, source_options, mac, device_name,
|
def interface_xml(type, source_options, mac, device_name,
|
||||||
iface_number, model_type, driver_options,
|
iface_number, model_type, mtu, driver_options,
|
||||||
udp_tunnel={})
|
udp_tunnel={})
|
||||||
Nokogiri::XML::Builder.new do |xml|
|
Nokogiri::XML::Builder.new do |xml|
|
||||||
xml.interface(type: type || 'network') do
|
xml.interface(type: type || 'network') do
|
||||||
@@ -245,6 +247,7 @@ module VagrantPlugins
|
|||||||
xml.target(dev: target_dev_name(device_name, type, iface_number))
|
xml.target(dev: target_dev_name(device_name, type, iface_number))
|
||||||
xml.alias(name: "net#{iface_number}")
|
xml.alias(name: "net#{iface_number}")
|
||||||
xml.model(type: model_type.to_s)
|
xml.model(type: model_type.to_s)
|
||||||
|
xml.mtu(size: mtu) if mtu
|
||||||
xml.driver(driver_options)
|
xml.driver(driver_options)
|
||||||
end
|
end
|
||||||
end.to_xml(
|
end.to_xml(
|
||||||
|
|||||||
@@ -286,6 +286,8 @@ module VagrantPlugins
|
|||||||
@network_bridge_name = @interface_network[:bridge_name]
|
@network_bridge_name = @interface_network[:bridge_name]
|
||||||
@network_address = @interface_network[:ip_address]
|
@network_address = @interface_network[:ip_address]
|
||||||
@network_netmask = @interface_network[:netmask]
|
@network_netmask = @interface_network[:netmask]
|
||||||
|
@network_mtu = @options[:mtu]
|
||||||
|
|
||||||
@guest_ipv6 = @interface_network[:guest_ipv6]
|
@guest_ipv6 = @interface_network[:guest_ipv6]
|
||||||
|
|
||||||
@network_ipv6_address = @interface_network[:ipv6_address]
|
@network_ipv6_address = @interface_network[:ipv6_address]
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
<domain name="<%= @network_domain_name %>" localOnly="yes" />
|
<domain name="<%= @network_domain_name %>" localOnly="yes" />
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if !@network_mtu.nil? %>
|
||||||
|
<mtu size="<%= @network_mtu %>" />
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if (@network_forward_mode != 'none' && @network_forward_mode != 'veryisolated') %>
|
<% if (@network_forward_mode != 'none' && @network_forward_mode != 'veryisolated') %>
|
||||||
<% if @network_forward_device %>
|
<% if @network_forward_device %>
|
||||||
<forward mode="<%= @network_forward_mode %>" dev="<%= @network_forward_device %>" />
|
<forward mode="<%= @network_forward_mode %>" dev="<%= @network_forward_device %>" />
|
||||||
|
|||||||
Reference in New Issue
Block a user