if libvirt version is < 10.10(below rhel 6.5), won't set nic throttling

(cherry picked from commit 6dc6e8a9007b502d66e44c5015b175aedcfa22ac)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/27924d1f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/27924d1f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/27924d1f

Branch: refs/heads/4.5
Commit: 27924d1f92231c760a17bf8c95b4da0db3466e83
Parents: 0fd9c43
Author: Edison Su <[email protected]>
Authored: Thu Oct 9 16:36:22 2014 -0700
Committer: David Nalley <[email protected]>
Committed: Mon Oct 13 00:38:25 2014 -0400

----------------------------------------------------------------------
 .../cloud/hypervisor/kvm/resource/BridgeVifDriver.java | 13 +++++++++++--
 .../kvm/resource/LibvirtComputingResource.java         |  1 +
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/27924d1f/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
index 3b034bb..b6814ba 100644
--- 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
+++ 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java
@@ -46,6 +46,7 @@ public class BridgeVifDriver extends VifDriverBase {
     private String _modifyVlanPath;
     private String _modifyVxlanPath;
     private String bridgeNameSchema;
+    private Long libvirtVersion;
 
     @Override
     public void configure(Map<String, Object> params) throws 
ConfigurationException {
@@ -74,6 +75,11 @@ public class BridgeVifDriver extends VifDriverBase {
             throw new ConfigurationException("Unable to find modifyvxlan.sh");
         }
 
+        libvirtVersion = (Long) params.get("libvirtVersion");
+        if (libvirtVersion == null) {
+            libvirtVersion = 0L;
+        }
+
         try {
             createControlNetwork();
         } catch (LibvirtException e) {
@@ -102,8 +108,12 @@ public class BridgeVifDriver extends VifDriverBase {
             throw new InternalErrorException("Nicira NVP Logicalswitches are 
not supported by the BridgeVifDriver");
         }
         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;
+        }
+
         if (nic.getType() == Networks.TrafficType.Guest) {
-            Integer networkRateKBps = (nic.getNetworkRateMbps() != null && 
nic.getNetworkRateMbps().intValue() != -1) ? 
nic.getNetworkRateMbps().intValue() * 128 : 0;
             if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) 
&& (vNetId != null) && (protocol != null) && 
(!vNetId.equalsIgnoreCase("untagged")) ||
                     (nic.getBroadcastType() == 
Networks.BroadcastDomainType.Vxlan)) {
                     if (trafficLabel != null && !trafficLabel.isEmpty()) {
@@ -122,7 +132,6 @@ public class BridgeVifDriver extends VifDriverBase {
             createControlNetwork();
             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;
             if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) 
&& (vNetId != null) && (protocol != null) && 
(!vNetId.equalsIgnoreCase("untagged")) ||
                     (nic.getBroadcastType() == 
Networks.BroadcastDomainType.Vxlan)) {
                 if (trafficLabel != null && !trafficLabel.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/27924d1f/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index d7b2af6..9a4ae16 100755
--- 
a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ 
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -953,6 +953,7 @@ public class LibvirtComputingResource extends 
ServerResourceBase implements Serv
         params.put("libvirt.host.pifs", _pifs);
 
         params.put("libvirt.computing.resource", this);
+        params.put("libvirtVersion", _hypervisorLibvirtVersion);
 
         configureVifDrivers(params);
 

Reply via email to