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.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;
 };