Change in vdsm[master]: net hostQos: maintain default class ls value

edwardh at redhat.com edwardh at redhat.com
Tue Feb 16 20:24:46 UTC 2016


Edward Haas has uploaded a new change for review.

Change subject: net hostQos: maintain default class ls value
......................................................................

net hostQos: maintain default class ls value

Devices (bond or nic) with tc settings, have default classes defined for
non-vlan traffic.
This patch keeps track of all classes defined on the device and updates
the default class 'ls' value with the maximum from all others.

Default classes that have been explicitly set through a non-vlan
network, override the max 'ls' logic described earlier.

Change-Id: I8eb296a33ff9f681dae4ab6ee79dfe75796ea1ed
Bug-Url: https://bugzilla.redhat.com/1302020
Signed-off-by: Edward Haas <edwardh at redhat.com>
---
M lib/vdsm/network/configurators/qos.py
1 file changed, 31 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/53623/1

diff --git a/lib/vdsm/network/configurators/qos.py b/lib/vdsm/network/configurators/qos.py
index 73f0e3b..604ce18 100644
--- a/lib/vdsm/network/configurators/qos.py
+++ b/lib/vdsm/network/configurators/qos.py
@@ -21,7 +21,7 @@
 import os
 from distutils.version import StrictVersion
 
-from vdsm.netinfo.cache import ifaceUsed
+from vdsm.netinfo.cache import ifaceUsed, CachingNetInfo
 from vdsm.netinfo import qos as netinfo_qos
 from vdsm import tc
 
@@ -157,6 +157,17 @@
     if class_id == _DEFAULT_CLASSID:
         _add_non_vlanned_filter(dev, root_qdisc_handle)
     else:
+        if not _is_explicit_defined_default_class(dev):
+            default_class, = [c['hfsc'] for c in tc.classes(
+                dev) if c['handle'] == _ROOT_QDISC_HANDLE + _DEFAULT_CLASSID]
+            ls_max_rate = _max_hfsc_ls_rate(dev)
+            default_class['ls']['m2'] = ls_max_rate
+
+            tc.cls.delete(dev, classid=_ROOT_QDISC_HANDLE + _DEFAULT_CLASSID)
+            _add_hfsc_cls(dev, _ROOT_QDISC_HANDLE, _DEFAULT_CLASSID,
+                          ls=default_class['ls'])
+            _add_fair_qdisc(dev, _ROOT_QDISC_HANDLE, _DEFAULT_CLASSID)
+
         _add_vlan_filter(dev, vlan_tag, root_qdisc_handle, class_id)
     _add_fair_qdisc(dev, root_qdisc_handle, class_id)
 
@@ -184,3 +195,22 @@
 def _add_hfsc_cls(dev, root_qdisc_handle, class_id, **qos_opts):
     tc.cls.add(dev, _SHAPING_QDISC_KIND, parent=root_qdisc_handle,
                classid=root_qdisc_handle + class_id, **qos_opts)
+
+
+def _is_explicit_defined_default_class(dev):
+    """
+    A default class is defined explicitly when a non-vlan network has hostQos
+    definitions.
+    """
+    netinfo = CachingNetInfo()
+    for _, attrs in netinfo.networks:
+        if 'vlan' not in attrs and 'hostQos' in attrs and (
+           attrs['iface'] == dev):
+            return True
+
+    return False
+
+
+def _max_hfsc_ls_rate(iface):
+    return max([cls['hfsc']['ls']['m2'] for cls in tc.classes(iface)
+                if cls['kind'] == 'hfsc' and 'root' not in cls])


-- 
To view, visit https://gerrit.ovirt.org/53623
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8eb296a33ff9f681dae4ab6ee79dfe75796ea1ed
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwardh at redhat.com>


More information about the vdsm-patches mailing list