Bug 9534 : implement CPU cap

Changes specific for Xen hypervisor, and DB upgrade. Changes for vmware chcked-in already in commit 1c310a0d2ae81108386f0dd5c2e899ff00fee9e9, e71112e2f587f5d6c9c6d5337cfeb1f239f29633. KVM will not support this feature.
This commit is contained in:
Murali Reddy 2011-05-02 13:06:02 +05:30
parent aae67e5d8d
commit 4fbcb02573
2 changed files with 10 additions and 6 deletions

View File

@ -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));

View File

@ -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` (