Change AdditionalData back to a vector in cereal

There is a case now where a system can create an event log with cereal
version 6 which will save the AdditionalData property as a map, but then
it can be backleveled to an image with version 5.  That code has no
knowledge of the map format, so cereal will throw an exception when it
attempts to restore the entry.

This will cause the daemon to go into an infinite crash/restart loop, as
it will always restart on failure.

A previous fix went in to catch any exceptions that cereal generates and
then throw away the log, but that won't help systems without that code.

To fix this, go back to saving AdditionalData as a vector, and then on
the load convert it to map after reading the file.  It still knows that
version 6 was saved as a map, so it can handle that appropriately.

With this fix, older code can load the cereal files created by the new
code.

Tested:
Created event log with version 7, copied the file to a system that only
understands version 5 and it can be restored properly.

Tested that version 6 can still be understood with the new code.

Change-Id: Ia49d8d2ba52398c4df5a15aa89df047b15047ac1
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/config/config.h.meson b/config/config.h.meson
index 0c3bb6d..93fd0e8 100644
--- a/config/config.h.meson
+++ b/config/config.h.meson
@@ -35,7 +35,8 @@
 static constexpr auto FIRST_CEREAL_CLASS_VERSION_WITH_EVENTID = "4";
 static constexpr auto FIRST_CEREAL_CLASS_VERSION_WITH_RESOLUTION = "5";
 static constexpr auto FIRST_CEREAL_CLASS_VERSION_WITH_METADATA_DICT = "6";
-static constexpr size_t CLASS_VERSION = 6;
+static constexpr auto FIRST_CEREAL_CLASS_VERSION_WITH_METADATA_VECTOR = "7";
+static constexpr size_t CLASS_VERSION = 7;
 
 static constexpr bool LG2_COMMIT_DBUS = @lg2_commit_dbus@;
 static constexpr bool LG2_COMMIT_JOURNAL = @lg2_commit_journal@;
diff --git a/elog_serialize.cpp b/elog_serialize.cpp
index 414fb4b..5c0f9cb 100644
--- a/elog_serialize.cpp
+++ b/elog_serialize.cpp
@@ -31,9 +31,10 @@
 template <class Archive>
 void save(Archive& a, const Entry& e, const std::uint32_t /*version*/)
 {
-    a(e.id(), e.severity(), e.timestamp(), e.message(), e.additionalData(),
-      e.associations(), e.resolved(), e.version(), e.updateTimestamp(),
-      e.eventId(), e.resolution());
+    a(e.id(), e.severity(), e.timestamp(), e.message(),
+      util::additional_data::combine(e.additionalData()), e.associations(),
+      e.resolved(), e.version(), e.updateTimestamp(), e.eventId(),
+      e.resolution());
 }
 
 /** @brief Function required by Cereal to perform deserialization.
@@ -98,11 +99,20 @@
           resolved, fwVersion, updateTimestamp, eventId, resolution);
         additionalData = util::additional_data::parse(additionalData_old);
     }
-    else
+    else if (version ==
+             std::stoul(FIRST_CEREAL_CLASS_VERSION_WITH_METADATA_DICT))
     {
         a(id, severity, timestamp, message, additionalData, associations,
           resolved, fwVersion, updateTimestamp, eventId, resolution);
     }
+    else
+    {
+        // Go back to reading a vector for additionalData
+        std::vector<std::string> additionalData_old{};
+        a(id, severity, timestamp, message, additionalData_old, associations,
+          resolved, fwVersion, updateTimestamp, eventId, resolution);
+        additionalData = util::additional_data::parse(additionalData_old);
+    }
 
     e.id(id, true);
     e.severity(severity, true);