Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 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 | { |
Ben Tyner | e8b2aed | 2020-12-16 18:58:41 -0600 | [diff] [blame] | 14 | // The host quiesce code will handle the instruction-stop task(s) |
| 15 | // thread_stop_all(); // in libpdbg |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 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 | |
Ben Tyner | fe2757b | 2021-01-14 13:17:50 -0600 | [diff] [blame] | 20 | // crash (mpipl) mode state requested |
| 21 | if (HostState::Crash == i_hostState) |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 22 | { |
Ben Tyner | fe2757b | 2021-01-14 13:17:50 -0600 | [diff] [blame] | 23 | target = "obmc-host-crash@0.target"; |
Ben Tyner | bcf65a8 | 2020-12-01 08:46:36 -0600 | [diff] [blame] | 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 |