Skip to content

Commit 9163013

Browse files
DK101010DK101010DaanHooglanddavidjumani
authored
Feat/ram reservation (#4662)
* remove hot enable cpu und memory in case of reservation ram and cpu reservation have not relation to ram and cpu hot add * add custom ram_reservation and it to vm details * system vms haven't this property, for this reason add additional check * Update plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java Co-authored-by: dahn <[email protected]> * replace 0.0 with NumberUtils * remove default value and remove return MinRam(seems to be not necessary) * Update plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java Co-authored-by: davidjumani <[email protected]> * Update plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java Co-authored-by: davidjumani <[email protected]> Co-authored-by: DK101010 <[email protected]> Co-authored-by: dahn <[email protected]> Co-authored-by: davidjumani <[email protected]>
1 parent 8bc120b commit 9163013

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public interface VmDetailConstants {
2929
String DATA_DISK_CONTROLLER = "dataDiskController";
3030
String SVGA_VRAM_SIZE = "svga.vramSize";
3131
String NESTED_VIRTUALIZATION_FLAG = "nestedVirtualizationFlag";
32+
String RAM_RESERVATION = "ramReservation";
3233

3334
// XenServer specific (internal)
3435
String HYPERVISOR_TOOLS_VERSION = "hypervisortoolsversion";

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/guru/VmwareVmImplementer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,4 @@ private NicTO[] sortNicsByDeviceId(NicTO[] nics) {
405405

406406
return listForSort.toArray(new NicTO[0]);
407407
}
408-
}
408+
}

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,6 @@ protected StartAnswer execute(StartCommand cmd) {
19761976
int scsiControllerKey = vmMo.getScsiDeviceControllerKeyNoException();
19771977
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
19781978
DiskTO[] sortedDisks = sortVolumesByDeviceId(disks);
1979-
19801979
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int) (vmSpec.getMaxRam() / (1024 * 1024)),
19811980
getReservedMemoryMb(vmSpec), guestOsId, vmSpec.getLimitCpuUse(), deployAsIs);
19821981

@@ -2977,6 +2976,10 @@ private void tearDownVm(VirtualMachineMO vmMo) throws Exception {
29772976

29782977
int getReservedMemoryMb(VirtualMachineTO vmSpec) {
29792978
if (vmSpec.getDetails().get(VMwareGuru.VmwareReserveMemory.key()).equalsIgnoreCase("true")) {
2979+
if(vmSpec.getDetails().get(VmDetailConstants.RAM_RESERVATION) != null){
2980+
float reservedMemory = (vmSpec.getMaxRam() * Float.parseFloat(vmSpec.getDetails().get(VmDetailConstants.RAM_RESERVATION)));
2981+
return (int) (reservedMemory / ResourceType.bytesToMiB);
2982+
}
29802983
return (int) (vmSpec.getMinRam() / ResourceType.bytesToMiB);
29812984
}
29822985
return 0;

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,6 +3822,7 @@ private void fillVMOrTemplateDetailOptions(final Map<String, List<String>> optio
38223822
options.put(VmDetailConstants.DATA_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "lsilogic", "lsisas1068", "buslogic", "pvscsi"));
38233823
options.put(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG, Arrays.asList("true", "false"));
38243824
options.put(VmDetailConstants.SVGA_VRAM_SIZE, Collections.emptyList());
3825+
options.put(VmDetailConstants.RAM_RESERVATION, Collections.emptyList());
38253826
}
38263827
}
38273828

vmware-base/src/main/java/com/cloud/hypervisor/vmware/util/VmwareHelper.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,6 @@ public static void setBasicVmConfig(VirtualMachineConfigSpec vmConfig, int cpuCo
548548

549549
cpuInfo.setReservation((long)cpuReservedMhz);
550550
vmConfig.setCpuAllocation(cpuInfo);
551-
if (cpuSpeedMHz != cpuReservedMhz) {
552-
vmConfig.setCpuHotAddEnabled(true);
553-
}
554-
if (memoryMB != memoryReserveMB) {
555-
vmConfig.setMemoryHotAddEnabled(true);
556-
}
557551
ResourceAllocationInfo memInfo = new ResourceAllocationInfo();
558552
memInfo.setLimit((long)memoryMB);
559553
memInfo.setReservation((long)memoryReserveMB);

0 commit comments

Comments
 (0)