Skip to content

Commit 6dc6e8a

Browse files
committed
if libvirt version is < 10.10(below rhel 6.5), won't set nic throttling
1 parent 15a2ea7 commit 6dc6e8a

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class BridgeVifDriver extends VifDriverBase {
4646
private String _modifyVlanPath;
4747
private String _modifyVxlanPath;
4848
private String bridgeNameSchema;
49+
private Long libvirtVersion;
4950

5051
@Override
5152
public void configure(Map<String, Object> params) throws ConfigurationException {
@@ -74,6 +75,11 @@ public void configure(Map<String, Object> params) throws ConfigurationException
7475
throw new ConfigurationException("Unable to find modifyvxlan.sh");
7576
}
7677

78+
libvirtVersion = (Long) params.get("libvirtVersion");
79+
if (libvirtVersion == null) {
80+
libvirtVersion = 0L;
81+
}
82+
7783
try {
7884
createControlNetwork();
7985
} catch (LibvirtException e) {
@@ -102,8 +108,12 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
102108
throw new InternalErrorException("Nicira NVP Logicalswitches are not supported by the BridgeVifDriver");
103109
}
104110
String trafficLabel = nic.getName();
111+
Integer networkRateKBps = 0;
112+
if (libvirtVersion > ((10 * 1000 + 10))) {
113+
networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
114+
}
115+
105116
if (nic.getType() == Networks.TrafficType.Guest) {
106-
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
107117
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) && (vNetId != null) && (protocol != null) && (!vNetId.equalsIgnoreCase("untagged")) ||
108118
(nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
109119
if (trafficLabel != null && !trafficLabel.isEmpty()) {
@@ -122,7 +132,6 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
122132
createControlNetwork();
123133
intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter));
124134
} else if (nic.getType() == Networks.TrafficType.Public) {
125-
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
126135
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) && (vNetId != null) && (protocol != null) && (!vNetId.equalsIgnoreCase("untagged")) ||
127136
(nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
128137
if (trafficLabel != null && !trafficLabel.isEmpty()) {

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
953953
params.put("libvirt.host.pifs", _pifs);
954954

955955
params.put("libvirt.computing.resource", this);
956+
params.put("libvirtVersion", _hypervisorLibvirtVersion);
956957

957958
configureVifDrivers(params);
958959

0 commit comments

Comments
 (0)