PHAL: add phal-export-devtree app
d-bus signal based watch app for software path interface add.
This implements methods for watching for software path
interface add signal and call appropriate function to
initiate phal devtree attribute data collection and save
to preserve partition.
Rules:
- Watch for interfaces added for the software path
- If interface added is “Activation”
- if Activation property value is “Ready”
- Then software update is going to start
- Collect phal devtree required attribute list and
save to pre-defined location
This commit enables the d-bus app only.
Tested : verified manually the signals by forcing
code update.
Jul 30 14:27:35 xxx phal-export-devtree[2624]: Software path
interface add signal received
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Change-Id: Ia1b7a87ef5a64e3c51c8dfa2d2e4ccef34a3e934
diff --git a/extensions/phal/fw_update_watch.cpp b/extensions/phal/fw_update_watch.cpp
new file mode 100644
index 0000000..a49cc9c
--- /dev/null
+++ b/extensions/phal/fw_update_watch.cpp
@@ -0,0 +1,87 @@
+#include "fw_update_watch.hpp"
+
+#include <fmt/format.h>
+
+#include <phosphor-logging/elog.hpp>
+#include <sdbusplus/exception.hpp>
+
+namespace openpower
+{
+namespace phal
+{
+namespace fwupdate
+{
+using namespace phosphor::logging;
+using Message = std::string;
+using Attributes = std::variant<Message>;
+using PropertyName = std::string;
+using PropertyMap = std::map<PropertyName, Attributes>;
+using InterfaceName = std::string;
+using InterfaceMap = std::map<InterfaceName, PropertyMap>;
+
+void Watch::fwIntfAddedCallback(sdbusplus::message::message& msg)
+{
+ // DBusInterfaceAdded interfaces;
+ sdbusplus::message::object_path objectPath;
+ InterfaceMap interfaceMap;
+
+ try
+ {
+ msg.read(objectPath, interfaceMap);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ log<level::ERR>(fmt::format("Failed to parse software add signal"
+ "Exception [{}] REPLY_SIG [{}]",
+ e.what(), msg.get_signature())
+ .c_str());
+ return;
+ }
+
+ auto iter = interfaceMap.find("xyz.openbmc_project.Software.Activation");
+ if (iter == interfaceMap.end())
+ {
+ // Skip not related Software Activation
+ return;
+ }
+
+ auto attr = iter->second.find("Activation");
+ if (attr == iter->second.end())
+ {
+ // Skip not related to Activation property.
+ return;
+ }
+
+ auto& imageProperty = std::get<InterfaceName>(attr->second);
+ if (imageProperty.empty())
+ {
+ // Skip, no image property
+ return;
+ }
+
+ if (imageProperty ==
+ "xyz.openbmc_project.Software.Activation.Activations.Ready" &&
+ !isSoftwareUpdateInProgress())
+ {
+ log<level::INFO>("Software path interface add signal received");
+
+ // Set status to code update in progress.
+ // Interface added signal triggered multiple times in code update path,
+ // it's due to additional interfaces added by the software manager app
+ // after the version interface is created.
+ // Device tree data collection is required only for the first trigger
+ setSoftwareUpdateProgress(true);
+
+ // Colect device tree data
+ openpower::phal::fwupdate::exportDevtree();
+ }
+
+ return;
+}
+
+void exportDevtree()
+{}
+
+} // namespace fwupdate
+} // namespace phal
+} // namespace openpower