mirror of https://github.com/apache/cloudstack.git
server: Set free memory to zero if greater than total memory (#4571)
Fixes https://github.com/apache/cloudstack/issues/4566 Sets `memoryintfreekbs` to zero if it is greater than `memorykbs`. Caused by KVM returning the RSS memory of the process running the VM rather than the free memory inside the VM. Co-authored-by: dahn <daan.hoogland@gmail.com>
This commit is contained in:
parent
d6a74272a4
commit
03ad702c1b
|
|
@ -209,7 +209,7 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
|
|||
private Long memoryKBs;
|
||||
|
||||
@SerializedName("memoryintfreekbs")
|
||||
@Param(description = "the internal memory thats free in vm")
|
||||
@Param(description = "the internal memory that's free in vm or zero if it can not be calculated")
|
||||
private Long memoryIntFreeKBs;
|
||||
|
||||
@SerializedName("memorytargetkbs")
|
||||
|
|
|
|||
|
|
@ -222,8 +222,11 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo
|
|||
userVmResponse.setDiskKbsWrite((long)vmStats.getDiskWriteKBs());
|
||||
userVmResponse.setDiskIORead((long)vmStats.getDiskReadIOs());
|
||||
userVmResponse.setDiskIOWrite((long)vmStats.getDiskWriteIOs());
|
||||
userVmResponse.setMemoryKBs((long)vmStats.getMemoryKBs());
|
||||
userVmResponse.setMemoryIntFreeKBs((long)vmStats.getIntFreeMemoryKBs());
|
||||
long totalMemory = (long)vmStats.getMemoryKBs();
|
||||
long freeMemory = (long)vmStats.getIntFreeMemoryKBs();
|
||||
long correctedFreeMemory = freeMemory >= totalMemory ? 0 : freeMemory;
|
||||
userVmResponse.setMemoryKBs(totalMemory);
|
||||
userVmResponse.setMemoryIntFreeKBs(correctedFreeMemory);
|
||||
userVmResponse.setMemoryTargetKBs((long)vmStats.getTargetMemoryKBs());
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue