diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index eda38edf31e..ec30c5b2e1e 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -245,8 +245,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe protected String _instance; //instance name (default is usually "VM") protected IAgentControl _agentControl; - - int _userVMCap = 0; + final int _maxWeight = 256; protected final XenServerHost _host = new XenServerHost(); @@ -791,16 +790,19 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe Integer speed = vmSpec.getSpeed(); if (speed != null) { - int utilization = _userVMCap; //cpu_cap - //Configuration cpu.uservm.cap is not available in default installation. Using this parameter is not encouraged - + int cpuWeight = _maxWeight; //cpu_weight - + int utilization = 0; // max CPU cap, default is unlimited + // weight based allocation cpuWeight = (int)((speed*0.99) / _host.speed * _maxWeight); if (cpuWeight > _maxWeight) { cpuWeight = _maxWeight; } + + if (vmSpec.getLimitCpuUse()) { + utilization = (int)((speed*0.99) / _host.speed * 100); + } vcpuParams.put("weight", Integer.toString(cpuWeight)); vcpuParams.put("cap", Integer.toString(utilization)); diff --git a/setup/db/db/schema-224to225.sql b/setup/db/db/schema-224to225.sql index 4bb38d5dcee..f48ab82f908 100644 --- a/setup/db/db/schema-224to225.sql +++ b/setup/db/db/schema-224to225.sql @@ -4,6 +4,8 @@ ALTER TABLE `cloud`.`mshost` ADD COLUMN `runid` bigint NOT NULL DEFAULT 0 COMMENT 'run id, combined with msid to form a cluster session'; ALTER TABLE `cloud`.`mshost` ADD COLUMN `state` varchar(10) NOT NULL default 'Down'; +ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `limit_cpu_use` tinyint(1) NOT NULL DEFAULT 0 ; +ALTER TABLE `cloud`.`service_offering` ADD COLUMN `limit_cpu_use` tinyint(1) NOT NULL DEFAULT 0 ; DROP TABLE IF EXISTS `cloud`.`certificate`; CREATE TABLE `cloud`.`keystore` (