[libvirt] [PATCH] network: apply bandwidth settings for forward mode=bridge

Daniel P. Berrangé posted 1 patch 4 years, 7 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190913160535.14779-1-berrange@redhat.com
src/network/bridge_driver.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
[libvirt] [PATCH] network: apply bandwidth settings for forward mode=bridge
Posted by Daniel P. Berrangé 4 years, 7 months ago
We previously allowed bandwidth settings when attaching NICs
to networks with forward mode=bridge:

  commit 42a92ee93d5432ebd9ebfd409903b5287fc7d7ff
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Tue Nov 20 11:30:05 2018 +0000

    network: add missing bandwidth limits for bridge forward type

    In the case of a network with forward=bridge, which has a bridge device
    listed, we are capable of setting bandwidth limits but fail to call the
    function to register them.

    Reviewed-by: Cole Robinson <crobinso@redhat.com>
    Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Unfortunately the wrong version of this patch was posted and
reviewed and thus it lacked the code to actually apply the
bandwidth settings to the bridge itself.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/network/bridge_driver.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 0fee153cb8..6a97bb17e2 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2743,21 +2743,39 @@ networkShutdownNetworkVirtual(virNetworkDriverStatePtr driver,
 static int
 networkStartNetworkBridge(virNetworkObjPtr obj)
 {
+    virNetworkDefPtr def = virNetworkObjGetDef(obj);
+
     /* 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.
      */
-    return networkStartHandleMACTableManagerMode(obj, NULL);
+    if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true, true) < 0)
+        goto error;
+
+    if (networkStartHandleMACTableManagerMode(obj, NULL) < 0)
+        goto error;
+
+    return 0;
+
+ error:
+    if (def->bandwidth)
+       virNetDevBandwidthClear(def->bridge);
+    return -1;
 }
 
 
 static int
 networkShutdownNetworkBridge(virNetworkObjPtr obj ATTRIBUTE_UNUSED)
 {
+    virNetworkDefPtr def = virNetworkObjGetDef(obj);
+
     /* put anything here that needs to be done each time a network of
      * type BRIDGE is shutdown. On failure, undo anything you've done,
      * and return -1. On success return 0.
      */
+    if (def->bandwidth)
+       virNetDevBandwidthClear(def->bridge);
+
     return 0;
 }
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] network: apply bandwidth settings for forward mode=bridge
Posted by Laine Stump 4 years, 7 months ago
On 9/13/19 12:05 PM, Daniel P. Berrangé wrote:
> We previously allowed bandwidth settings when attaching NICs
> to networks with forward mode=bridge:
>
>    commit 42a92ee93d5432ebd9ebfd409903b5287fc7d7ff
>    Author: Daniel P. Berrangé <berrange@redhat.com>
>    Date:   Tue Nov 20 11:30:05 2018 +0000
>
>      network: add missing bandwidth limits for bridge forward type
>
>      In the case of a network with forward=bridge, which has a bridge device
>      listed, we are capable of setting bandwidth limits but fail to call the
>      function to register them.
>
>      Reviewed-by: Cole Robinson <crobinso@redhat.com>
>      Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
>
> Unfortunately the wrong version of this patch was posted and
> reviewed and thus it lacked the code to actually apply the
> bandwidth settings to the bridge itself.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


Reviewed-by: Laine Stump <laine@laine.org>


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list