PEL: Prevent deletion if it's associated with HWIsolation
- This ensures that PELs linked to HWIsolation records are protected
from accidental deletion.
- Shows error message of "Call failed: The service is temporarily
unavailable.", when attempting to delete such a PEL individually.
- If trying to Delete all, will skip such PELs without showing any
message.
Tested:
Sample output:
```bash
$ busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/
logging xyz.openbmc_project.Collection.DeleteAll DeleteAll
$ busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/
logging/entry/2 xyz.openbmc_project.Object.Delete Delete
Call failed: The service is temporarily unavailable.
```
Change-Id: I2d28de91bbb0fbc2a991e3d5e5631814d41fe044
Signed-off-by: Harsh Agarwal <Harsh.Agarwal@ibm.com>
diff --git a/extensions.hpp b/extensions.hpp
index c10e6a0..ff74137 100644
--- a/extensions.hpp
+++ b/extensions.hpp
@@ -50,6 +50,16 @@
*/
using DeleteProhibitedFunction = std::function<void(uint32_t, bool&)>;
+/**
+ * @brief The function type that will return list of Hw Isolated
+ * log IDs
+ * @param[out] std::vector<uint32_t>& - Hw Isolated log IDs
+ */
+using LogIDWithHwIsolationFunction =
+ std::function<void(std::vector<uint32_t>&)>;
+using LogIDsWithHwIsolationFunctions =
+ std::vector<LogIDWithHwIsolationFunction>;
+
using StartupFunctions = std::vector<StartupFunction>;
using CreateFunctions = std::vector<CreateFunction>;
using DeleteFunctions = std::vector<DeleteFunction>;
@@ -159,6 +169,19 @@
}
/**
+ * @brief Constructor to register a LogID with HwIsolation function
+ *
+ * Functions registered with this contructor will be called
+ * before phosphor-log-manager deletes all event log.
+ *
+ * @param[in] func - The function to register
+ */
+ explicit Extensions(LogIDWithHwIsolationFunction func)
+ {
+ getLogIDWithHwIsolationFunctions().emplace_back(func);
+ }
+
+ /**
* @brief Constructor to disable event log capping
*
* This constructor should only be called by the
@@ -197,6 +220,13 @@
static DeleteProhibitedFunctions& getDeleteProhibitedFunctions();
/**
+ * @brief Returns the LogIDWithHwIsolationFunction functions
+ * @return LogIDsWithHwIsolationFunctions - the LogIDWithHwIsolationFunction
+ * functions
+ */
+ static LogIDsWithHwIsolationFunctions& getLogIDWithHwIsolationFunctions();
+
+ /**
* @brief Returns the DefaultErrorCaps value
* @return DefaultErrorCaps - the DefaultErrorCaps value
*/