[PATCH 1/1] bridge_driver: use ovs-vsctl to setup and clean Qos when

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: zhangjl02 <zhangjl02@xxxxxxxxxx>

Fix bug 1826168: bridge type network with ovs bridge can start with Qos
setting which do not take any effect

Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=1826168
Signed-off-by: zhangjl02 <zhangjl02@xxxxxxxxxx>
---
 src/network/bridge_driver.c | 65 +++++++++++++++++++++++++++++++------
 1 file changed, 55 insertions(+), 10 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 498c45d0a7..d0627848cd 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2305,6 +2305,15 @@ networkAddRouteToBridge(virNetworkObj *obj,
 }
 
 
+static int
+networkDefIsOvsBridge(virNetworkDef *def)
+{
+    const virNetDevVPortProfile *vport = def->virtPortProfile;
+    return vport &&
+        vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH;
+}
+
+
 static int
 networkStartNetworkVirtual(virNetworkDriverState *driver,
                            virNetworkObj *obj)
@@ -2320,6 +2329,7 @@ networkStartNetworkVirtual(virNetworkDriverState *driver,
     bool dnsmasqStarted = false;
     bool devOnline = false;
     bool firewalRulesAdded = false;
+    bool ovsType = networkDefIsOvsBridge(def);
 
     /* Check to see if any network IP collides with an existing route */
     if (networkCheckRouteCollision(def) < 0)
@@ -2439,15 +2449,29 @@ networkStartNetworkVirtual(virNetworkDriverState *driver,
     if (v6present && networkStartRadvd(driver, obj) < 0)
         goto error;
 
-    if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true, true) < 0)
-        goto error;
+    if (ovsType) {
+        if (virNetDevOpenvswitchInterfaceSetQos(def->bridge, def->bandwidth,
+                                                def->uuid,
+                                                true) < 0)
+            goto error;
+    } else {
+        if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true, true) < 0)
+            goto error;
+    }
 
     return 0;
 
  error:
     virErrorPreserveLast(&save_err);
-    if (def->bandwidth)
-       virNetDevBandwidthClear(def->bridge);
+    if (ovsType) {
+        if (virNetDevOpenvswitchInterfaceClearQos(def->bridge, def->uuid) < 0)
+            VIR_WARN("cannot clear bandwidth setting for ovs bridge : %s",
+                     def->bridge);
+    } else {
+        if (def->bandwidth) {
+            virNetDevBandwidthClear(def->bridge);
+        }
+    }
 
     if (dnsmasqStarted) {
         pid_t dnsmasqPid = virNetworkObjGetDnsmasqPid(obj);
@@ -2536,13 +2560,21 @@ static int
 networkStartNetworkBridge(virNetworkObj *obj)
 {
     virNetworkDef *def = virNetworkObjGetDef(obj);
+    bool ovsType = networkDefIsOvsBridge(def);
 
     /* put anything here that needs to be done each time a network of
      * type BRIDGE, is started. On failure, undo anything you've done,
      * and return -1. On success return 0.
      */
-    if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true, true) < 0)
-        goto error;
+    if (ovsType) {
+        if (virNetDevOpenvswitchInterfaceSetQos(def->bridge, def->bandwidth,
+                                                def->uuid,
+                                                true) < 0)
+            goto error;
+    } else {
+        if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true, true) < 0)
+            goto error;
+    }
 
     if (networkStartHandleMACTableManagerMode(obj) < 0)
         goto error;
@@ -2550,8 +2582,15 @@ networkStartNetworkBridge(virNetworkObj *obj)
     return 0;
 
  error:
-    if (def->bandwidth)
-       virNetDevBandwidthClear(def->bridge);
+    if (ovsType) {
+        if (virNetDevOpenvswitchInterfaceClearQos(def->bridge, def->uuid) < 0)
+            VIR_WARN("cannot clear bandwidth setting for ovs bridge : %s",
+                     def->bridge);
+    } else {
+        if (def->bandwidth) {
+            virNetDevBandwidthClear(def->bridge);
+        }
+    }
     return -1;
 }
 
@@ -2565,9 +2604,15 @@ networkShutdownNetworkBridge(virNetworkObj *obj G_GNUC_UNUSED)
      * type BRIDGE is shutdown. On failure, undo anything you've done,
      * and return -1. On success return 0.
      */
-    if (def->bandwidth)
-       virNetDevBandwidthClear(def->bridge);
 
+    if (networkDefIsOvsBridge(def)) {
+        if (virNetDevOpenvswitchInterfaceClearQos(def->bridge, def->uuid) < 0)
+            VIR_WARN("cannot clear bandwidth setting for ovs bridge : %s",
+                     def->bridge);
+    } else {
+        if (def->bandwidth)
+            virNetDevBandwidthClear(def->bridge);
+    }
     return 0;
 }
 
-- 
2.30.2.windows.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux