Update persistent power cap data filename
Renamed the file that holds the persistent power cap limits.
Also will only use the data if the version field matches.
This will prevent a conflict with the old power cap data.
Verified on Rainier.
Change-Id: Ifc0a16ac8df557b7453a0fb4f4f8962f6fc70a31
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/powercap.cpp b/powercap.cpp
index 573024c..2116d49 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -79,13 +79,17 @@
PowerCapData newCapData;
std::ifstream stream{ipath.c_str(), std::ios_base::binary};
stream.read((char*)&newCapData, sizeof(newCapData));
- if (newCapData.version != PCAPDATA_FILE_VERSION)
+ if (newCapData.version == PCAPDATA_FILE_VERSION)
{
- lg2::warning(
+ memcpy(&capData, &newCapData, sizeof(capData));
+ }
+ else
+ {
+ lg2::error(
"OccPersistCapData::load() file version was {VER} (expected {EXP})",
"VER", newCapData.version, "EXP", PCAPDATA_FILE_VERSION);
+ capData.initialized = false;
}
- memcpy(&capData, &newCapData, sizeof(capData));
}
catch (const std::exception& e)
{
diff --git a/powercap.hpp b/powercap.hpp
index c46b6b9..fab3918 100644
--- a/powercap.hpp
+++ b/powercap.hpp
@@ -103,7 +103,7 @@
private:
/** @brief Power Mode data filename to store persistent data */
- static constexpr auto powerCapFilename = "powerCapData";
+ static constexpr auto powerCapFilename = "powerCapLimitData";
/** @brief Power Mode data object to be persisted */
PowerCapData capData;