xref: /openbmc/openpower-hw-diags/attn/attn_common.cpp (revision fe2757b0883a17d87561ecfc44d5c3a692f1373d)
1 #include <libpdbg.h>
2 
3 #include <attn/attn_common.hpp>
4 #include <sdbusplus/bus.hpp>
5 
6 #include <map>
7 
8 namespace attn
9 {
10 
11 /** @brief Transition the host state */
12 void transitionHost(const HostState i_hostState)
13 {
14     // The host quiesce code will handle the instruction-stop task(s)
15     // thread_stop_all(); // in libpdbg
16 
17     // We will be transitioning host by starting appropriate dbus target
18     std::string target = "obmc-host-quiesce@0.target"; // quiesce is default
19 
20     // crash (mpipl) mode state requested
21     if (HostState::Crash == i_hostState)
22     {
23         target = "obmc-host-crash@0.target";
24     }
25 
26     auto bus    = sdbusplus::bus::new_system();
27     auto method = bus.new_method_call(
28         "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
29         "org.freedesktop.systemd1.Manager", "StartUnit");
30 
31     method.append(target);    // target unit to start
32     method.append("replace"); // mode = replace conflicting queued jobs
33 
34     bus.call_noreply(method); // start the service
35 }
36 
37 } // namespace attn
38