Attn: Quiesce host on SBE vital
When an SBE vital is detected the attention handler will transition the
host to the quiesce state. Code has also been added to make a call to
thread_stop_all (libpdbg) before transitioning host (mpipl and
quiesce cases).
Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: Idac4680e2cb9eacedb6be7b70ae8b0d60dde66b5
diff --git a/attn/attn_common.cpp b/attn/attn_common.cpp
new file mode 100644
index 0000000..3e1f473
--- /dev/null
+++ b/attn/attn_common.cpp
@@ -0,0 +1,36 @@
+#include <libpdbg.h>
+
+#include <attn/attn_common.hpp>
+#include <sdbusplus/bus.hpp>
+
+#include <map>
+
+namespace attn
+{
+
+/** @brief Transition the host state */
+void transitionHost(const HostState i_hostState)
+{
+ thread_stop_all(); // in libpdbg
+
+ // We will be transitioning host by starting appropriate dbus target
+ std::string target = "obmc-host-quiesce@0.target"; // quiesce is default
+
+ // diagnostic mode state requested
+ if (HostState::Diagnostic == i_hostState)
+ {
+ target = "obmc-host-diagnostic-mode@0.target";
+ }
+
+ auto bus = sdbusplus::bus::new_system();
+ auto method = bus.new_method_call(
+ "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager", "StartUnit");
+
+ method.append(target); // target unit to start
+ method.append("replace"); // mode = replace conflicting queued jobs
+
+ bus.call_noreply(method); // start the service
+}
+
+} // namespace attn