Skip to content

Network rate must be multiplied by 125 not 128 #10645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
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);

Check warning on line 210 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L210 was not covered by tests
}

if (nic.getType() == Networks.TrafficType.Guest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

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.
Expand All @@ -42,13 +41,14 @@
* @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);

Check warning on line 51 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/DirectVifDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L51 was not covered by tests
intf.defDirectNet(_libvirtComputingResource.getNetworkDirectDevice(), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter),
_libvirtComputingResource.getNetworkDirectSourceMode(), networkRateKBps);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
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);

Check warning on line 96 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/IvsVifDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L96 was not covered by tests
if (nic.getType() == Networks.TrafficType.Guest) {
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) &&
!vlanId.equalsIgnoreCase("untagged")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
}
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()) {
Expand Down Expand Up @@ -162,7 +162,7 @@
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);

Check warning on line 165 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L165 was not covered by tests
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
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");
Expand Down Expand Up @@ -78,4 +80,13 @@
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;

Check warning on line 86 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/VifDriverBase.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/VifDriverBase.java#L86

Added line #L86 was not covered by tests
}
else {
return 0;
}
}
}
Loading