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 1e6d1be32e..4770dd1e4e 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3229,7 +3229,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)
@@ -3250,9 +3250,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:
@@ -3293,15 +3299,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:
@@ -3310,6 +3307,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:
@@ -4578,6 +4585,9 @@ networkAllocateActualDevice(virNetworkPtr net,
goto error;
}
}
+
+ if (networkPlugBandwidth(obj, iface) < 0)
+ goto error;
break;
}
@@ -5052,6 +5062,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:
@@ -5460,7 +5475,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