mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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 <daan.hoogland@gmail.com> * 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 <dj.davidjumani1994@gmail.com> * Update plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java Co-authored-by: davidjumani <dj.davidjumani1994@gmail.com> Co-authored-by: DK101010 <dirk.klahre@itelligence.de> Co-authored-by: dahn <daan.hoogland@gmail.com> Co-authored-by: davidjumani <dj.davidjumani1994@gmail.com>
This commit is contained in:
parent
8bc120b288
commit
9163013683
@ -29,6 +29,7 @@ public interface VmDetailConstants {
|
||||
String DATA_DISK_CONTROLLER = "dataDiskController";
|
||||
String SVGA_VRAM_SIZE = "svga.vramSize";
|
||||
String NESTED_VIRTUALIZATION_FLAG = "nestedVirtualizationFlag";
|
||||
String RAM_RESERVATION = "ramReservation";
|
||||
|
||||
// XenServer specific (internal)
|
||||
String HYPERVISOR_TOOLS_VERSION = "hypervisortoolsversion";
|
||||
|
||||
@ -405,4 +405,4 @@ class VmwareVmImplementer {
|
||||
|
||||
return listForSort.toArray(new NicTO[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1976,7 +1976,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
int scsiControllerKey = vmMo.getScsiDeviceControllerKeyNoException();
|
||||
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
|
||||
DiskTO[] sortedDisks = sortVolumesByDeviceId(disks);
|
||||
|
||||
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int) (vmSpec.getMaxRam() / (1024 * 1024)),
|
||||
getReservedMemoryMb(vmSpec), guestOsId, vmSpec.getLimitCpuUse(), deployAsIs);
|
||||
|
||||
@ -2977,6 +2976,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
|
||||
int getReservedMemoryMb(VirtualMachineTO vmSpec) {
|
||||
if (vmSpec.getDetails().get(VMwareGuru.VmwareReserveMemory.key()).equalsIgnoreCase("true")) {
|
||||
if(vmSpec.getDetails().get(VmDetailConstants.RAM_RESERVATION) != null){
|
||||
float reservedMemory = (vmSpec.getMaxRam() * Float.parseFloat(vmSpec.getDetails().get(VmDetailConstants.RAM_RESERVATION)));
|
||||
return (int) (reservedMemory / ResourceType.bytesToMiB);
|
||||
}
|
||||
return (int) (vmSpec.getMinRam() / ResourceType.bytesToMiB);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -3822,6 +3822,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
||||
options.put(VmDetailConstants.DATA_DISK_CONTROLLER, Arrays.asList("osdefault", "ide", "scsi", "lsilogic", "lsisas1068", "buslogic", "pvscsi"));
|
||||
options.put(VmDetailConstants.NESTED_VIRTUALIZATION_FLAG, Arrays.asList("true", "false"));
|
||||
options.put(VmDetailConstants.SVGA_VRAM_SIZE, Collections.emptyList());
|
||||
options.put(VmDetailConstants.RAM_RESERVATION, Collections.emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -548,12 +548,6 @@ public class VmwareHelper {
|
||||
|
||||
cpuInfo.setReservation((long)cpuReservedMhz);
|
||||
vmConfig.setCpuAllocation(cpuInfo);
|
||||
if (cpuSpeedMHz != cpuReservedMhz) {
|
||||
vmConfig.setCpuHotAddEnabled(true);
|
||||
}
|
||||
if (memoryMB != memoryReserveMB) {
|
||||
vmConfig.setMemoryHotAddEnabled(true);
|
||||
}
|
||||
ResourceAllocationInfo memInfo = new ResourceAllocationInfo();
|
||||
memInfo.setLimit((long)memoryMB);
|
||||
memInfo.setReservation((long)memoryReserveMB);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user