diag-mode: support entry into diagnostic mode
See DiagnosticMode definition in phosphor-dbus-interfaces for more
information:
https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/State/Host.interface.yaml
This target will be started by other software entities within OpenBMC so
phosphor-host-state-manager will monitor for this target to start and
update its state accordingly. System defined behavior will then
transition the system out of this state (quiesce, off, warm-reboot) and
state-manager will update as needed when those are seen.
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: Ide599058dfe5596c3f40c9c295dd1259853b15a7
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index d9b0319..bdc2a86 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -49,6 +49,8 @@
constexpr auto HOST_STATE_WARM_REBOOT = "obmc-host-warm-reboot@0.target";
constexpr auto HOST_STATE_FORCE_WARM_REBOOT =
"obmc-host-force-warm-reboot@0.target";
+constexpr auto HOST_STATE_DIAGNOSTIC_MODE =
+ "obmc-host-diagnostic-mode@0.target";
constexpr auto HOST_STATE_QUIESCE_TGT = "obmc-host-quiesce@0.target";
@@ -274,6 +276,22 @@
}
}
+void Host::sysStateChangeJobNew(sdbusplus::message::message& msg)
+{
+ uint32_t newStateID{};
+ sdbusplus::message::object_path newStateObjPath;
+ std::string newStateUnit{};
+
+ // Read the msg and populate each variable
+ msg.read(newStateID, newStateObjPath, newStateUnit);
+
+ if (newStateUnit == HOST_STATE_DIAGNOSTIC_MODE)
+ {
+ log<level::INFO>("Received signal that host is in diagnostice mode");
+ this->currentHostState(server::Host::HostState::DiagnosticMode);
+ }
+}
+
uint32_t Host::decrementRebootCount()
{
auto rebootCount = reboot::RebootAttempts::attemptsLeft();
diff --git a/host_state_manager.hpp b/host_state_manager.hpp
index 149cecc..c57c8aa 100644
--- a/host_state_manager.hpp
+++ b/host_state_manager.hpp
@@ -58,6 +58,13 @@
sdbusRule::interface("org.freedesktop.systemd1.Manager"),
std::bind(std::mem_fn(&Host::sysStateChangeJobRemoved), this,
std::placeholders::_1)),
+ systemdSignalJobNew(
+ bus,
+ sdbusRule::type::signal() + sdbusRule::member("JobNew") +
+ sdbusRule::path("/org/freedesktop/systemd1") +
+ sdbusRule::interface("org.freedesktop.systemd1.Manager"),
+ std::bind(std::mem_fn(&Host::sysStateChangeJobNew), this,
+ std::placeholders::_1)),
settings(bus)
{
// Enable systemd signals
@@ -163,6 +170,19 @@
*/
void sysStateChangeJobRemoved(sdbusplus::message::message& msg);
+ /** @brief Check if JobNew systemd signal is relevant to this object
+ *
+ * In certain instances phosphor-state-manager needs to monitor for the
+ * entry into a systemd target. This function will be used for these cases.
+ *
+ * Instance specific interface to handle the detected systemd state
+ * change
+ *
+ * @param[in] msg - Data associated with subscribed signal
+ *
+ */
+ void sysStateChangeJobNew(sdbusplus::message::message& msg);
+
/** @brief Decrement reboot count
*
* This is used internally to this application to decrement the boot
@@ -250,6 +270,9 @@
/** @brief Used to subscribe to dbus systemd JobRemoved signal **/
sdbusplus::bus::match_t systemdSignalJobRemoved;
+ /** @brief Used to subscribe to dbus systemd JobNew signal **/
+ sdbusplus::bus::match_t systemdSignalJobNew;
+
// Settings objects of interest
settings::Objects settings;
};