diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1ec6455d14c9a8bdd664c7cb2f40825816b20760..a7ad8a2bf0b7efc1ac1145932f0d73bdb8b22890 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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"); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index eb9a00f5cf23e8146d75b03aa84e46a52bf34ba6..379b7dcef9d6a07722ffb792d970809227c82417 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -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 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 element " + "in network %s with forward mode='%s'"), + def->name, + virNetworkForwardTypeToString(def->forward.type)); + return -1; + } + /* we support configs with a single PF defined: * * 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;