Minor power on hours serialization changes
In preparation for the chassis manager class persisting
another data member, some changes need to be made to the
POH serialization code to make it consistent with saving
individual data members in separate files.
1) Remove the load()/save() functions from the Chassis class.
Cereal only requires those when archiving a custom object,
like when the Host class uses oarchive(*this).
2) Remove the Cereal version define from the Chassis class.
That is also only used when a custom object is serialized,
and in fact the version wasn't being stored in the serialized
data anyway.
3) Rename the POH serialization/deserialization functions to be
specifically for the POH counter.
These don't affect how or where POH value is persisted.
Tested: Verify the POH value still increments and survives
reboots.
Change-Id: I065e1a24e018b66f284c6a00f9a34d24eaaedc36
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index 03dd176..a723d8f 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -9,9 +9,6 @@
#include "config.h"
#include <experimental/filesystem>
-// Register class version with Cereal
-CEREAL_CLASS_VERSION(phosphor::state::manager::Chassis, CLASS_VERSION);
-
namespace phosphor
{
namespace state
@@ -269,7 +266,7 @@
if (value != pOHCounter())
{
ChassisInherit::pOHCounter(value);
- serialize();
+ serializePOH();
}
return pOHCounter();
}
@@ -277,7 +274,7 @@
void Chassis::restorePOHCounter()
{
uint32_t counter;
- if (!deserialize(POH_COUNTER_PERSIST_PATH, counter))
+ if (!deserializePOH(POH_COUNTER_PERSIST_PATH, counter))
{
// set to default value
pOHCounter(0);
@@ -288,7 +285,7 @@
}
}
-fs::path Chassis::serialize(const fs::path& path)
+fs::path Chassis::serializePOH(const fs::path& path)
{
std::ofstream os(path.c_str(), std::ios::binary);
cereal::JSONOutputArchive oarchive(os);
@@ -296,7 +293,7 @@
return path;
}
-bool Chassis::deserialize(const fs::path& path, uint32_t& pOHCounter)
+bool Chassis::deserializePOH(const fs::path& path, uint32_t& pOHCounter)
{
try
{
diff --git a/chassis_state_manager.hpp b/chassis_state_manager.hpp
index a1fcb04..5532949 100644
--- a/chassis_state_manager.hpp
+++ b/chassis_state_manager.hpp
@@ -137,34 +137,6 @@
/** @brief Used to restore POHCounter value from persisted file */
void restorePOHCounter();
- /** @brief Function required by Cereal to perform serialization.
- *
- * @tparam Archive - Cereal archive type (json in our case).
- * @param[in] archive - reference to Cereal archive.
- * @param[in] version - Class version that enables handling
- * a serialized data across code levels
- */
- template <class Archive>
- inline void save(Archive& archive, const std::uint32_t version) const
- {
- archive(pOHCounter());
- }
-
- /** @brief Function required by Cereal to perform deserialization.
- *
- * @tparam Archive - Cereal archive type (json in our case).
- * @param[in] archive - reference to Cereal archive.
- * @param[in] version - Class version that enables handling
- * a serialized data across code levels
- */
- template <class Archive>
- inline void load(Archive& archive, const std::uint32_t version)
- {
- uint32_t value;
- archive(value);
- pOHCounter(value);
- }
-
/** @brief Serialize and persist requested POH counter.
*
* @param[in] dir - pathname of file where the serialized POH counter will
@@ -173,9 +145,9 @@
* @return fs::path - pathname of persisted requested POH counter.
*/
fs::path
- serialize(const fs::path& dir = fs::path(POH_COUNTER_PERSIST_PATH));
+ serializePOH(const fs::path& dir = fs::path(POH_COUNTER_PERSIST_PATH));
- /** @brief Deserialze a persisted requested POH counter.
+ /** @brief Deserialize a persisted requested POH counter.
*
* @param[in] path - pathname of persisted POH counter file
* @param[in] retCounter - deserialized POH counter value
@@ -183,7 +155,7 @@
* @return bool - true if the deserialization was successful, false
* otherwise.
*/
- bool deserialize(const fs::path& path, uint32_t& retCounter);
+ bool deserializePOH(const fs::path& path, uint32_t& retCounter);
/** @brief Timer */
std::unique_ptr<phosphor::state::manager::Timer> timer;