mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Network rate must be multiplied by 125 not 128 (#10645)
* Network rate must be multiplied by 125 not 128 In a libvirt domain xml when nw_rate=5000 the kilobytes per second configured in the interface is 640000 which is 5.12 Gbit/s. Which is more than the configured network rate of 5Gbit/s. So instead multiply by 125. * Apply suggestions from code review Co-authored-by: Suresh Kumar Anaparti <sureshkumar.anaparti@gmail.com>
This commit is contained in:
parent
1994511f0c
commit
e57e8cf418
@ -211,7 +211,7 @@ public class BridgeVifDriver extends VifDriverBase {
|
||||
String trafficLabel = nic.getName();
|
||||
Integer networkRateKBps = 0;
|
||||
if (libvirtVersion > ((10 * 1000 + 10))) {
|
||||
networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
networkRateKBps = getNetworkRateKbps(nic);
|
||||
}
|
||||
|
||||
if (nic.getType() == Networks.TrafficType.Guest) {
|
||||
|
||||
@ -30,7 +30,6 @@ import java.util.Map;
|
||||
|
||||
public class DirectVifDriver extends VifDriverBase {
|
||||
|
||||
|
||||
/**
|
||||
* Experimental driver to configure direct networking in libvirt. This should only
|
||||
* be used on an LXC cluster that does not run any system VMs.
|
||||
@ -42,13 +41,14 @@ public class DirectVifDriver extends VifDriverBase {
|
||||
* @throws InternalErrorException
|
||||
* @throws LibvirtException
|
||||
*/
|
||||
|
||||
@Override
|
||||
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
|
||||
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
|
||||
|
||||
if (Sets.newHashSet(Networks.TrafficType.Guest,
|
||||
Networks.TrafficType.Public).contains(nic.getType())) {
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
Integer networkRateKBps = getNetworkRateKbps(nic);
|
||||
intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter),
|
||||
_libvirtComputingResource.getNetworkDirectSourceMode(), networkRateKBps);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ public class IvsVifDriver extends VifDriverBase {
|
||||
vlanId = NetUtils.getPrimaryPvlanFromUri(nic.getBroadcastUri());
|
||||
}
|
||||
String trafficLabel = nic.getName();
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
Integer networkRateKBps = getNetworkRateKbps(nic);
|
||||
if (nic.getType() == Networks.TrafficType.Guest) {
|
||||
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) &&
|
||||
!vlanId.equalsIgnoreCase("untagged")) {
|
||||
|
||||
@ -130,7 +130,7 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
}
|
||||
String trafficLabel = nic.getName();
|
||||
if (nic.getType() == Networks.TrafficType.Guest) {
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
Integer networkRateKBps = getNetworkRateKbps(nic);
|
||||
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) &&
|
||||
!vlanId.equalsIgnoreCase("untagged")) {
|
||||
if (trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
@ -162,7 +162,7 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
createControlNetwork(_bridges.get("linklocal"));
|
||||
intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter));
|
||||
} else if (nic.getType() == Networks.TrafficType.Public) {
|
||||
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
|
||||
Integer networkRateKBps = getNetworkRateKbps(nic);
|
||||
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vlanId.equalsIgnoreCase("untagged")) {
|
||||
if (trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
logger.debug("creating a vlan dev and bridge for public traffic per traffic label " + trafficLabel);
|
||||
|
||||
@ -40,6 +40,8 @@ public abstract class VifDriverBase implements VifDriver {
|
||||
protected Map<String, String> _pifs;
|
||||
protected Map<String, String> _bridges;
|
||||
|
||||
protected static final int bitsPerMbpsToKbps = 125;
|
||||
|
||||
@Override
|
||||
public void configure(Map<String, Object> params) throws ConfigurationException {
|
||||
_libvirtComputingResource = (LibvirtComputingResource)params.get("libvirt.computing.resource");
|
||||
@ -78,4 +80,11 @@ public abstract class VifDriverBase implements VifDriver {
|
||||
public boolean isExistingBridge(String bridgeName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static int getNetworkRateKbps(NicTO nic) {
|
||||
if (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) {
|
||||
return nic.getNetworkRateMbps().intValue() * bitsPerMbpsToKbps;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user