cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject git commit: updated refs/heads/master to 726114a
Date Mon, 12 Aug 2013 03:31:37 GMT
Updated Branches:
  refs/heads/master 21b09fc55 -> 726114a95


CLOUDSTACK-3850: CPU cap should be per VM not per VCPU

Signed-off-by: Koushik Das <koushik@apache.org>


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

Branch: refs/heads/master
Commit: 726114a95df0c0525617225e07295b8dff10a8af
Parents: 21b09fc
Author: Harikrishna Patnala <harikrishna.patnala@citrix.com>
Authored: Sun Aug 11 00:37:36 2013 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Mon Aug 12 08:59:18 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/hypervisor/xen/resource/CitrixResourceBase.java   | 4 ++--
 .../cloud/hypervisor/xen/resource/XenServer56FP1Resource.java   | 5 +++--
 .../cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java   | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/726114a9/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
index 978bfde..ecdec1e 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java
@@ -653,14 +653,14 @@ public abstract class CitrixResourceBase implements ServerResource,
HypervisorRe
 
             // weight based allocation
 
-            cpuWeight = (int)((speed*0.99) / _host.speed * _maxWeight);
+            cpuWeight = (int)((speed * 0.99) / _host.speed * _maxWeight);
             if (cpuWeight > _maxWeight) {
                 cpuWeight = _maxWeight;
             }
 
             if (vmSpec.getLimitCpuUse()) {
                 long utilization = 0; // max CPU cap, default is unlimited
-                utilization = ((long)speed * 100 * vmSpec.getCpus()) / _host.speed ;
+                utilization = (int) ((speed * 0.99 * vmSpec.getCpus()) / _host.speed * 100);
                 //vm.addToVCPUsParamsLive(conn, "cap", Long.toString(utilization)); currently
xenserver doesnot support Xapi to add VCPUs params live.
                 callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live", "key", "cap", "value",
Long.toString(utilization), "vmname", vmSpec.getName() );
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/726114a9/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
index d230be1..214dbd4 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56FP1Resource.java
@@ -223,14 +223,15 @@ public class XenServer56FP1Resource extends XenServer56Resource {
             int cpuWeight = _maxWeight; // cpu_weight
             int utilization = 0; // max CPU cap, default is unlimited
 
-            // weight based allocation
+            // weight based allocation, CPU weight is calculated per VCPU
             cpuWeight = (int) ((speed * 0.99) / _host.speed * _maxWeight);
             if (cpuWeight > _maxWeight) {
                 cpuWeight = _maxWeight;
             }
 
             if (vmSpec.getLimitCpuUse()) {
-                utilization = (int) ((speed * 0.99) / _host.speed * 100);
+                // CPU cap is per VM, so need to assign cap based on the number of vcpus
+                utilization = (int) ((speed * 0.99 * vmSpec.getCpus()) / _host.speed * 100);
             }
 
             vcpuParams.put("weight", Integer.toString(cpuWeight));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/726114a9/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
index cb16ae2..920d6d2 100644
--- a/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
+++ b/plugins/hypervisors/xen/test/com/cloud/hypervisor/xen/resource/CitrixResourceBaseTest.java
@@ -145,7 +145,7 @@ public class CitrixResourceBaseTest {
         doNothing().when(vm).setVCPUsNumberLive(conn, 1L);
         doReturn(500).when(vmSpec).getMinSpeed();
         doReturn(true).when(vmSpec).getLimitCpuUse();
-        doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live",
"key", "cap", "value", "100", "vmname", "i-2-3-VM");
+        doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live",
"key", "cap", "value", "99", "vmname", "i-2-3-VM");
         Map<String, String> args = (Map<String, String>)mock(HashMap.class);
         when(host.callPlugin(conn, "vmops", "add_to_VCPUs_params_live", args)).thenReturn("Success");
         doReturn(null).when(_resource).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live",
"key", "weight", "value", "253", "vmname", "i-2-3-VM");
@@ -154,6 +154,6 @@ public class CitrixResourceBaseTest {
 
         verify(vmSpec, times(1)).getLimitCpuUse();
         verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live",
"key", "weight", "value", "253", "vmname", "i-2-3-VM");
-        verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live",
"key", "cap", "value", "100", "vmname", "i-2-3-VM");
+        verify(_resource, times(1)).callHostPlugin(conn, "vmops", "add_to_VCPUs_params_live",
"key", "cap", "value", "99", "vmname", "i-2-3-VM");
     }
 }
\ No newline at end of file


Mime
View raw message