fix reserved memory is zero

This commit is contained in:
wanyaoqi
2019-10-17 10:46:01 +08:00
parent e61191f0eb
commit 94642c2ec0
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -831,6 +831,9 @@ func (h *SHostInfo) getReservedMem() int {
if reserved > options.HostOptions.MaxReservedMemory {
return options.HostOptions.MaxReservedMemory
}
if reserved == 0 {
panic("memory reserve value is 0, need help")
}
return reserved
}
+4
View File
@@ -152,6 +152,10 @@ func DetectMemoryInfo() (*SMemory, error) {
return nil, err
}
smem.MemInfo = sysutils.ParseDMIMemInfo(strings.Split(string(ret), "\n"))
if smem.MemInfo.Total == 0 {
// in case dmidecode is not work, use gopsutil
smem.MemInfo.Total = smem.Total
}
return smem, nil
}