Fix No Total Memory Size Issue
Total Memory in redfish is always 0, fix the problem.
Tested:
After DC cycle the system. TotalSystemMemoryGiB in Redfish system page should
not be zero.
"MemorySummary": {
"Status": {
"State": "Enabled"
},
"TotalSystemMemoryGiB": 16
},
Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com>
Change-Id: I89ad8ed1cf5f9ca9589db444740167645dab9a6e
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 0e6cb09..ce12ed7 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -215,26 +215,45 @@
VariantType>
&property : properties)
{
- if (property.first ==
- "MemorySizeInKb")
+ if (property.first !=
+ "MemorySizeInKB")
{
- const uint64_t *value =
- sdbusplus::message::
- variant_ns::get_if<
- uint64_t>(
- &property.second);
- if (value != nullptr)
- {
- aResp->res.jsonValue
- ["TotalSystemMemoryGi"
- "B"] +=
- *value / (1024 * 1024);
- aResp->res.jsonValue
- ["MemorySummary"]
- ["Status"]["State"] =
- "Enabled";
- }
+ continue;
}
+ const uint32_t *value =
+ sdbusplus::message::variant_ns::
+ get_if<uint32_t>(
+ &property.second);
+ if (value == nullptr)
+ {
+ BMCWEB_LOG_DEBUG
+ << "Find incorrect type of "
+ "MemorySize";
+ continue;
+ }
+ nlohmann::json &totalMemory =
+ aResp->res
+ .jsonValue["MemorySummar"
+ "y"]
+ ["TotalSystemMe"
+ "moryGiB"];
+ uint64_t *preValue =
+ totalMemory
+ .get_ptr<uint64_t *>();
+ if (preValue == nullptr)
+ {
+ continue;
+ }
+ aResp->res
+ .jsonValue["MemorySummary"]
+ ["TotalSystemMemoryGi"
+ "B"] =
+ *value / (1024 * 1024) +
+ *preValue;
+ aResp->res
+ .jsonValue["MemorySummary"]
+ ["Status"]["State"] =
+ "Enabled";
}
}
else
@@ -1669,7 +1688,7 @@
res.jsonValue["Description"] = "Computer System";
res.jsonValue["ProcessorSummary"]["Count"] = 0;
res.jsonValue["ProcessorSummary"]["Status"]["State"] = "Disabled";
- res.jsonValue["MemorySummary"]["TotalSystemMemoryGiB"] = int(0);
+ res.jsonValue["MemorySummary"]["TotalSystemMemoryGiB"] = uint64_t(0);
res.jsonValue["MemorySummary"]["Status"]["State"] = "Disabled";
res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system";