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.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/network/bridge_driver.c | 39 ++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 314939cb17..0e6279e7c1 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3239,7 +3239,7 @@ networkValidate(virNetworkDriverStatePtr driver,
virPortGroupDefPtr defaultPortGroup = NULL;
virNetworkIPDefPtr ipdef;
bool ipv4def = false, ipv6def = false;
- bool bandwidthAllowed = true;
+ bool bandwidthAllowed = false;
bool usesInterface = false, usesAddress = false;
if (virXMLCheckIllegalChars("name", def->name, "\n") < 0)
@@ -3260,9 +3260,15 @@ networkValidate(virNetworkDriverStatePtr driver,
return -1;
virNetworkSetBridgeMacAddr(def);
+ bandwidthAllowed = true;
break;
case VIR_NETWORK_FORWARD_BRIDGE:
+ if (def->bridge != NULL)
+ bandwidthAllowed = true;
+
+ ATTRIBUTE_FALLTHROUGH;
+
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
case VIR_NETWORK_FORWARD_PASSTHROUGH:
@@ -3303,15 +3309,6 @@ networkValidate(virNetworkDriverStatePtr driver,
virNetworkForwardTypeToString(def->forward.type));
return -1;
}
- if (def->bandwidth) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Unsupported network-wide <bandwidth> element
"
- "in network %s with forward mode='%s'"),
- def->name,
- virNetworkForwardTypeToString(def->forward.type));
- return -1;
- }
- bandwidthAllowed = false;
break;
case VIR_NETWORK_FORWARD_LAST:
@@ -3320,6 +3317,16 @@ networkValidate(virNetworkDriverStatePtr driver,
return -1;
}
+ if (def->bandwidth &&
+ !bandwidthAllowed) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported network-wide <bandwidth> element "
+ "in network %s with forward mode='%s'"),
+ def->name,
+ virNetworkForwardTypeToString(def->forward.type));
+ return -1;
+ }
+
/* we support configs with a single PF defined:
* <pf dev='eth0'/>
* or with a list of netdev names:
@@ -4588,6 +4595,9 @@ networkAllocateActualDevice(virNetworkPtr net,
goto error;
}
}
+
+ if (networkPlugBandwidth(obj, iface) < 0)
+ goto error;
break;
}
@@ -5062,6 +5072,11 @@ networkReleaseActualDevice(virNetworkPtr net,
break;
case VIR_NETWORK_FORWARD_BRIDGE:
+ if (iface->data.network.actual &&
+ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE &&
+ networkUnplugBandwidth(obj, iface) < 0)
+ goto error;
+ break;
case VIR_NETWORK_FORWARD_PRIVATE:
case VIR_NETWORK_FORWARD_VEPA:
case VIR_NETWORK_FORWARD_PASSTHROUGH:
@@ -5470,7 +5485,9 @@ networkBandwidthGenericChecks(virDomainNetDefPtr iface,
virNetDevBandwidthPtr ifaceBand;
unsigned long long old_floor, new_floor;
- if (virDomainNetGetActualType(iface) != VIR_DOMAIN_NET_TYPE_NETWORK) {
+ if (virDomainNetGetActualType(iface) != VIR_DOMAIN_NET_TYPE_NETWORK &&
+ (virDomainNetGetActualType(iface) != VIR_DOMAIN_NET_TYPE_BRIDGE ||
+ iface->data.network.actual->data.bridge.brname == NULL)) {
/* This is not an interface that's plugged into a network.
* We don't care. Thus from our POV bandwidth change is allowed. */
return false;
--
2.20.1