blob: fce3d54ddd970f8b8576982db315398c22014fb4 [file] [log] [blame]
Ben Tynerbcf65a82020-12-01 08:46:36 -06001#include <libpdbg.h>
2
3#include <attn/attn_common.hpp>
4#include <sdbusplus/bus.hpp>
5
6#include <map>
7
8namespace attn
9{
10
11/** @brief Transition the host state */
12void transitionHost(const HostState i_hostState)
13{
Ben Tynere8b2aed2020-12-16 18:58:41 -060014 // The host quiesce code will handle the instruction-stop task(s)
15 // thread_stop_all(); // in libpdbg
Ben Tynerbcf65a82020-12-01 08:46:36 -060016
17 // We will be transitioning host by starting appropriate dbus target
18 std::string target = "obmc-host-quiesce@0.target"; // quiesce is default
19
Ben Tynerfe2757b2021-01-14 13:17:50 -060020 // crash (mpipl) mode state requested
21 if (HostState::Crash == i_hostState)
Ben Tynerbcf65a82020-12-01 08:46:36 -060022 {
Ben Tynerfe2757b2021-01-14 13:17:50 -060023 target = "obmc-host-crash@0.target";
Ben Tynerbcf65a82020-12-01 08:46:36 -060024 }
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