Skip to content

Commit 806a9e0

Browse files
committed
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.
1 parent 2dfe6a6 commit 806a9e0

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
public class BridgeVifDriver extends VifDriverBase {
4545

4646
private int _timeout;
47+
private int bitsPerMbpsToKbps = 125;
4748

4849
private final Object _vnetBridgeMonitor = new Object();
4950
private String _modifyVlanPath;
@@ -207,7 +208,7 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
207208
String trafficLabel = nic.getName();
208209
Integer networkRateKBps = 0;
209210
if (libvirtVersion > ((10 * 1000 + 10))) {
210-
networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
211+
networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * bitsPerMbpsToKbps : 0;
211212
}
212213

213214
if (nic.getType() == Networks.TrafficType.Guest) {

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/DirectVifDriver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.util.Map;
3030

3131
public class DirectVifDriver extends VifDriverBase {
32-
32+
private int bitsPerMbpsToKbps = 125;
3333

3434
/**
3535
* Experimental driver to configure direct networking in libvirt. This should only
@@ -42,13 +42,14 @@ public class DirectVifDriver extends VifDriverBase {
4242
* @throws InternalErrorException
4343
* @throws LibvirtException
4444
*/
45+
4546
@Override
4647
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
4748
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
4849

4950
if (Sets.newHashSet(Networks.TrafficType.Guest,
5051
Networks.TrafficType.Public).contains(nic.getType())) {
51-
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
52+
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * bitsPerMbpsToKbps : 0;
5253
intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter),
5354
_libvirtComputingResource.getNetworkDirectSourceMode(), networkRateKBps);
5455
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/IvsVifDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
public class IvsVifDriver extends VifDriverBase {
4343
private int _timeout;
44+
private int bitsPerMbpsToKbps = 125;
4445

4546
private final Object _vnetBridgeMonitor = new Object();
4647
private String _modifyVlanPath;
@@ -93,7 +94,7 @@ public InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<S
9394
vlanId = NetUtils.getPrimaryPvlanFromUri(nic.getBroadcastUri());
9495
}
9596
String trafficLabel = nic.getName();
96-
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
97+
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * bitsPerMbpsToKbps : 0;
9798
if (nic.getType() == Networks.TrafficType.Guest) {
9899
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) &&
99100
!vlanId.equalsIgnoreCase("untagged")) {

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
public class OvsVifDriver extends VifDriverBase {
4747
private int _timeout;
48+
private int bitsPerMbpsToKbps = 125;
4849
private String _controlCidr = NetUtils.getLinkLocalCIDR();
4950
private DpdkDriver dpdkDriver;
5051

@@ -130,7 +131,7 @@ public InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<S
130131
}
131132
String trafficLabel = nic.getName();
132133
if (nic.getType() == Networks.TrafficType.Guest) {
133-
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
134+
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * bitsPerMbpsToKbps : 0;
134135
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) &&
135136
!vlanId.equalsIgnoreCase("untagged")) {
136137
if (trafficLabel != null && !trafficLabel.isEmpty()) {
@@ -162,7 +163,7 @@ public InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter, Map<S
162163
createControlNetwork(_bridges.get("linklocal"));
163164
intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter));
164165
} else if (nic.getType() == Networks.TrafficType.Public) {
165-
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
166+
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * bitsPerMbpsToKbps : 0;
166167
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vlanId.equalsIgnoreCase("untagged")) {
167168
if (trafficLabel != null && !trafficLabel.isEmpty()) {
168169
logger.debug("creating a vlan dev and bridge for public traffic per traffic label " + trafficLabel);

0 commit comments

Comments
 (0)