summaryrefslogtreecommitdiff
path: root/nova/virt
diff options
context:
space:
mode:
authorSean Mooney <sean.k.mooney@intel.com>2018-03-14 21:00:33 +0000
committerLee Yarwood <lyarwood@redhat.com>2018-07-04 17:33:26 +0100
commit127dd738c0ec67f3559774bae83dd8872e616991 (patch)
tree55e55bd6320c457ee48d520c8812f606d7938377 /nova/virt
parent710be2a04cd6ef0e8ddad0d957873133e1f60ebc (diff)
downloadnova-127dd738c0ec67f3559774bae83dd8872e616991.tar.gz
add mtu to libvirt xml for ethernet and bridge types
Where libvirt is creating the tap device e.g: OVS bridge (hybrid=False). os-vif will just ensure that the OVS bridge exists. We want libvirt to create the tap, configure the MTU and then plug the tap into the right bridge. - This change adds the mtu element to libvirt guest interface xml for vifs of type ethernet and bridge. - This change adds a libvirt version check to enable setting the interface mtu on hosts with libvirt 3.3.0+ Conflicts: nova/virt/libvirt/vif.py NOTE(lyarwood): This conflict is due to the removal of IVS plug/unplug via dIcf948f6ee1c0da2327fb5eac61fec6e89ac30531 during Rocky, resulting in the eventual master change having to reintroduce get_config_bridge that is already present in stable/queens. Change-Id: Iecc265fb25e88fa00a66f1fd38e215cad53e7669 Partial-bug: #1747496 (cherry picked from commit f02b3800051234ecc14f3117d5987b1a8ef75877)
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/libvirt/config.py7
-rw-r--r--nova/virt/libvirt/designer.py7
-rw-r--r--nova/virt/libvirt/vif.py22
3 files changed, 36 insertions, 0 deletions
diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py
index 0c0e6ee0f9..6725ddcac7 100644
--- a/nova/virt/libvirt/config.py
+++ b/nova/virt/libvirt/config.py
@@ -1328,6 +1328,7 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
self.vif_outbound_average = None
self.vlan = None
self.device_addr = None
+ self.mtu = None
def format_dom(self):
dev = super(LibvirtConfigGuestInterface, self).format_dom()
@@ -1348,6 +1349,8 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
if self.net_type == "ethernet":
if self.script is not None:
dev.append(etree.Element("script", path=self.script))
+ if self.mtu is not None:
+ dev.append(etree.Element("mtu", size=str(self.mtu)))
elif self.net_type == "direct":
dev.append(etree.Element("source", dev=self.source_dev,
mode=self.source_mode))
@@ -1370,6 +1373,8 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
dev.append(etree.Element("source", bridge=self.source_dev))
if self.script is not None:
dev.append(etree.Element("script", path=self.script))
+ if self.mtu is not None:
+ dev.append(etree.Element("mtu", size=str(self.mtu)))
else:
dev.append(etree.Element("source", bridge=self.source_dev))
@@ -1501,6 +1506,8 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
elif c.tag == 'address':
obj = LibvirtConfigGuestDeviceAddress.parse_dom(c)
self.device_addr = obj
+ elif c.tag == 'mtu':
+ self.mtu = int(c.get('size'))
def add_filter_param(self, key, value):
self.filterparams.append({'key': key, 'value': value})
diff --git a/nova/virt/libvirt/designer.py b/nova/virt/libvirt/designer.py
index 847faa6598..9448847937 100644
--- a/nova/virt/libvirt/designer.py
+++ b/nova/virt/libvirt/designer.py
@@ -158,6 +158,13 @@ def set_vif_host_backend_vhostuser_config(conf, mode, path):
conf.vhostuser_path = path
+def set_vif_mtu_config(conf, mtu):
+ """Populate a LibvirtConfigGuestInterface instance
+ with network mtu.
+ """
+ conf.mtu = mtu
+
+
def set_vif_bandwidth_config(conf, inst_type):
"""Config vif inbound/outbound bandwidth limit. parameters are
set in instance_type_extra_specs table, key is in the format
diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py
index 6d5f2385e9..6b2ad06b33 100644
--- a/nova/virt/libvirt/vif.py
+++ b/nova/virt/libvirt/vif.py
@@ -48,6 +48,8 @@ CONF = nova.conf.CONF
MIN_LIBVIRT_VHOSTUSER_MQ = (1, 2, 17)
# vlan tag for macvtap passthrough mode on SRIOV VFs
MIN_LIBVIRT_MACVTAP_PASSTHROUGH_VLAN = (1, 3, 5)
+# setting interface mtu was intoduced in libvirt 3.3
+MIN_LIBVIRT_INTERFACE_MTU = (3, 3, 0)
def is_vif_model_valid_for_virt(virt_type, vif_model):
@@ -237,8 +239,23 @@ class LibvirtGenericVIFDriver(object):
conf.filtername = name
designer.set_vif_bandwidth_config(conf, inst_type)
+ self._set_mtu_config(vif, host, conf)
+
return conf
+ def _set_mtu_config(self, vif, host, conf):
+ """:param vif: nova.network.modle.vif
+ :param host: nova.virt.libvirt.host.Host
+ :param conf: nova.virt.libvirt.config.LibvirtConfigGuestInterface
+ """
+ network = vif.get('network')
+ if (network and network.get_meta("mtu") and
+ self._has_min_version_for_mtu(host)):
+ designer.set_vif_mtu_config(conf, network.get_meta("mtu"))
+
+ def _has_min_version_for_mtu(self, host):
+ return host.has_min_version(MIN_LIBVIRT_INTERFACE_MTU)
+
def get_config_ivs_hybrid(self, instance, vif, image_meta,
inst_type, virt_type, host):
newvif = copy.deepcopy(vif)
@@ -404,6 +421,8 @@ class LibvirtGenericVIFDriver(object):
dev = self.get_vif_devname(vif)
designer.set_vif_host_backend_ethernet_config(conf, dev, host)
+ self._set_mtu_config(vif, host, conf)
+
return conf
def _get_vhostuser_settings(self, vif):
@@ -530,6 +549,9 @@ class LibvirtGenericVIFDriver(object):
func(instance, vif, conf, host)
designer.set_vif_bandwidth_config(conf, inst_type)
+ if ('network' in vif and 'mtu' in vif.network and
+ self._has_min_version_for_mtu(host)):
+ designer.set_vif_mtu_config(conf, vif.network.mtu)
return conf