PEL: Delete event logs with bad PELs

There are two cases where there would be an OpenBMC D-Bus event log
without an associated PEL:
1) The event log/PEL came from the host, and the PEL was malformed.
2) The event log/PEL came from hostboot, and the ID of the PEL is
   already in use by an existing PEL so the PEL is archived.

This commit will delete the OpenBMC D-Bus event logs in these cases
pretty much right after they are created, because:

a) Host originated D-Bus event logs are aren't useful for either service
nor debug since the PEL contains all of the useful information.

b) These event logs aren't seen by the PEL code's size/space management
algorithms that delete logs, so they continue to accumulate, taking up
more and more space in the serialization directory and possibly slowing
down D-Bus calls that act on all entries.

While this shouldn't really occur that often, there isn't anything the
BMC can do to keep it from happening since it's due to host issues.

An alternative could be to delay emitting the InterfacesAdded signal
until after the event log extension code runs and have that code say if
it is OK to create the event log or not, but as most users of
phosphor-logging don't use extensions it seems more intrusive. Also, if
there are multiple extensions and only one is upset, it isn't that clear
what should happen.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I6c7faf47c1c340ecbce0771bfe667560720ee269
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp
index 42ce0c4..8d0079d 100644
--- a/extensions/openpower-pels/manager.hpp
+++ b/extensions/openpower-pels/manager.hpp
@@ -425,6 +425,21 @@
     void createPELEntry(uint32_t obmcLogID, bool skipIaSignal = false);
 
     /**
+     * @brief Schedules the delete of the OpenBMC event log for when
+     *        execution gets back to the event loop (uses sd_event_add_defer).
+     *
+     * @param[in] obmcLogID - The OpenBMC entry log ID
+     */
+    void scheduleObmcLogDelete(uint32_t obmcLogID);
+
+    /**
+     * @brief SD event callback to delete an OpenBMC event log
+     *
+     * @param[in] obmcLogID - The OpenBMC entry log ID
+     */
+    void deleteObmcLog(sdeventplus::source::EventBase&, uint32_t obmcLogID);
+
+    /**
      * @brief Reference to phosphor-logging's Manager class
      */
     phosphor::logging::internal::Manager& _logManager;
@@ -483,6 +498,12 @@
     std::unique_ptr<sdeventplus::source::Defer> _repoPrunerEventSource;
 
     /**
+     * @brief The event source for deleting an OpenBMC event log.
+     *        Used when its corresponding PEL is invalid.
+     */
+    std::unique_ptr<sdeventplus::source::Defer> _obmcLogDeleteEventSource;
+
+    /**
      * @brief The even source for watching for deleted PEL files.
      */
     std::unique_ptr<sdeventplus::source::IO> _pelFileDeleteEventSource;