blob: ed21ba875116c40c00bbc5535cbb9b29465ab31b [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
20 // diagnostic mode state requested
21 if (HostState::Diagnostic == i_hostState)
22 {
23 target = "obmc-host-diagnostic-mode@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