summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-10-05 12:43:19 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-10-06 13:29:52 +0530
commit0a83873508c542b21f99e2b5e1a2605f91916f4f (patch)
tree5b5469d61fab993255cd05ac26dd30c2ff8d4783
parent4e6534f5b2520228a275941e2f3f5a495f41b9aa (diff)
downloadphosphor-state-manager-0a83873508c542b21f99e2b5e1a2605f91916f4f.tar.gz
phosphor-state-manager-0a83873508c542b21f99e2b5e1a2605f91916f4f.zip
Enable Cereal class versioning
Cereal class versioning helps to handle data de-serialization across different class versions that differ in the way, a particular data is serialized. For more reading, refer Cereal official documentation; http://uscilab.github.io/cereal/serialization_functions.html Change-Id: Ic5d01090b7a7679ef2bf638da786abbd033007bc Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rw-r--r--configure.ac4
-rw-r--r--host_state_manager.cpp2
-rw-r--r--host_state_manager.hpp9
3 files changed, 13 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 28f51ae..49bc3dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,5 +69,9 @@ AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.
AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])])
AC_CHECK_HEADER(phosphor-logging/log.hpp, ,[AC_MSG_ERROR([Could not find phosphor-logging/log.hpp...openbmc/phosphor-logging package required])])
+AC_ARG_VAR(CLASS_VERSION, [Class version to register with Cereal])
+AS_IF([test "x$CLASS_VERSION" == "x"], [CLASS_VERSION=1])
+AC_DEFINE_UNQUOTED([CLASS_VERSION], [$CLASS_VERSION], [Class version to register with Cereal])
+
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index 8debe8a..884372d 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -16,6 +16,8 @@
#include "host_state_manager.hpp"
#include "config.h"
+// Register class version with Cereal
+CEREAL_CLASS_VERSION(phosphor::state::manager::Host, CLASS_VERSION);
namespace phosphor
{
diff --git a/host_state_manager.hpp b/host_state_manager.hpp
index 35a4bdd..6b5e97e 100644
--- a/host_state_manager.hpp
+++ b/host_state_manager.hpp
@@ -4,6 +4,7 @@
#include <functional>
#include <experimental/filesystem>
#include <cereal/access.hpp>
+#include <cereal/cereal.hpp>
#include <sdbusplus/bus.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
@@ -184,9 +185,11 @@ class Host : public HostInherit
*
* @tparam Archive - Cereal archive type (binary 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>
- void save(Archive& archive) const
+ void save(Archive& archive, const std::uint32_t version) const
{
archive(convertForMessage(sdbusplus::xyz::openbmc_project::
State::server::Host::
@@ -203,9 +206,11 @@ class Host : public HostInherit
*
* @tparam Archive - Cereal archive type (binary 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>
- void load(Archive& archive)
+ void load(Archive& archive, const std::uint32_t version)
{
std::string reqTranState;
std::string bootProgress;
OpenPOWER on IntegriCloud