Skip to content

Commit 2e28f69

Browse files
committed
CLOUDSTACK-1410: >4.1 agents should be able to communicatie with <=4.1 management servers
The recently added overcommit feature breaks compatibility between older management servers and 4.2 agents. This patch fixes that by falling back if needed.
1 parent ddd507b commit 2e28f69

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

api/src/com/cloud/agent/api/to/VirtualMachineTO.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,20 @@ public class VirtualMachineTO {
2828
private BootloaderType bootloader;
2929
Type type;
3030
int cpus;
31+
32+
/**
33+
'speed' is still here since 4.0.X/4.1.X management servers do not support
34+
the overcommit feature yet.
35+
36+
The overcommit feature sends minSpeed and maxSpeed
37+
38+
So this is here for backwards compatibility with 4.0.X/4.1.X management servers
39+
and newer agents.
40+
*/
41+
Integer speed;
3142
Integer minSpeed;
3243
Integer maxSpeed;
44+
3345
long minRam;
3446
long maxRam;
3547
String hostName;
@@ -103,6 +115,10 @@ public void setCpus(int cpus) {
103115
this.cpus = cpus;
104116
}
105117

118+
public Integer getSpeed() {
119+
return speed;
120+
}
121+
106122
public Integer getMinSpeed() {
107123
return minSpeed;
108124
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2934,7 +2934,21 @@ protected LibvirtVMDef createVMFromSpec(VirtualMachineTO vmTO) {
29342934
vm.addComp(grd);
29352935

29362936
CpuTuneDef ctd = new CpuTuneDef();
2937-
ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
2937+
/**
2938+
A 4.0.X/4.1.X management server doesn't send the correct JSON
2939+
command for getMinSpeed, it only sends a 'speed' field.
2940+
2941+
So if getMinSpeed() returns null we fall back to getSpeed().
2942+
2943+
This way a >4.1 agent can work communicate a <=4.1 management server
2944+
2945+
This change is due to the overcommit feature in 4.2
2946+
*/
2947+
if (vmTO.getMinSpeed() != null) {
2948+
ctd.setShares(vmTO.getCpus() * vmTO.getMinSpeed());
2949+
} else {
2950+
ctd.setShares(vmTO.getCpus() * vmTO.getSpeed());
2951+
}
29382952
vm.addComp(ctd);
29392953

29402954
FeaturesDef features = new FeaturesDef();

0 commit comments

Comments
 (0)