提交 42a92ee9 编写于 作者: D Daniel P. Berrangé

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: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 bbe2aa62
......@@ -11172,8 +11172,10 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
hostdev, flags) < 0) {
goto error;
}
} else if (actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
} else if (actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
VIR_AUTOFREE(char *) class_id = NULL;
xmlNodePtr sourceNode;
class_id = virXPathString("string(./class/@id)", ctxt);
if (class_id &&
......@@ -11183,10 +11185,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
class_id);
goto error;
}
}
if (actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
xmlNodePtr sourceNode = virXPathNode("./source", ctxt);
sourceNode = virXPathNode("./source", ctxt);
if (sourceNode) {
char *brname = virXMLPropString(sourceNode, "bridge");
......
......@@ -3249,7 +3249,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)
......@@ -3270,9 +3270,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:
......@@ -3313,15 +3319,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:
......@@ -3330,6 +3327,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:
......@@ -4598,6 +4605,9 @@ networkAllocateActualDevice(virNetworkPtr net,
goto error;
}
}
if (networkPlugBandwidth(obj, iface) < 0)
goto error;
break;
}
......@@ -5061,6 +5071,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:
......@@ -5469,7 +5484,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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册