Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 3 | #include "config.h" |
| 4 | |
| 5 | #include "settings.hpp" |
Andrew Geissler | 928bbf1 | 2023-02-14 13:30:14 -0600 | [diff] [blame] | 6 | #include "utils.hpp" |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 7 | |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 8 | #include <cereal/access.hpp> |
Vishwanatha Subbanna | 0a83873 | 2017-10-05 12:43:19 +0530 | [diff] [blame] | 9 | #include <cereal/cereal.hpp> |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 10 | #include <phosphor-logging/lg2.hpp> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 11 | #include <sdbusplus/bus.hpp> |
Dhruvaraj Subhashchandran | 2710e73 | 2017-06-19 06:43:22 -0500 | [diff] [blame] | 12 | #include <xyz/openbmc_project/Control/Boot/RebootAttempts/server.hpp> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 13 | #include <xyz/openbmc_project/State/Boot/Progress/server.hpp> |
Patrick Williams | 9a286db | 2024-01-17 06:29:47 -0600 | [diff] [blame] | 14 | #include <xyz/openbmc_project/State/Host/server.hpp> |
Dhruvaraj Subhashchandran | 2710e73 | 2017-06-19 06:43:22 -0500 | [diff] [blame] | 15 | #include <xyz/openbmc_project/State/OperatingSystem/Status/server.hpp> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 16 | |
Patrick Williams | 6ed41ea | 2022-04-05 15:50:21 -0500 | [diff] [blame] | 17 | #include <filesystem> |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 18 | #include <string> |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 19 | |
| 20 | namespace phosphor |
| 21 | { |
| 22 | namespace state |
| 23 | { |
| 24 | namespace manager |
| 25 | { |
| 26 | |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 27 | using HostInherit = sdbusplus::server::object_t< |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 28 | sdbusplus::server::xyz::openbmc_project::state::Host, |
| 29 | sdbusplus::server::xyz::openbmc_project::state::boot::Progress, |
| 30 | sdbusplus::server::xyz::openbmc_project::control::boot::RebootAttempts, |
| 31 | sdbusplus::server::xyz::openbmc_project::state::operating_system::Status>; |
Dhruvaraj Subhashchandran | 2710e73 | 2017-06-19 06:43:22 -0500 | [diff] [blame] | 32 | |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 33 | PHOSPHOR_LOG2_USING; |
Andrew Geissler | 7b90a62 | 2017-08-08 11:41:08 -0500 | [diff] [blame] | 34 | |
Patrick Williams | d22706f | 2017-05-04 05:42:49 -0500 | [diff] [blame] | 35 | namespace sdbusRule = sdbusplus::bus::match::rules; |
Patrick Williams | 6ed41ea | 2022-04-05 15:50:21 -0500 | [diff] [blame] | 36 | namespace fs = std::filesystem; |
Patrick Williams | d22706f | 2017-05-04 05:42:49 -0500 | [diff] [blame] | 37 | |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 38 | /** @class Host |
| 39 | * @brief OpenBMC host state management implementation. |
| 40 | * @details A concrete implementation for xyz.openbmc_project.State.Host |
| 41 | * DBus API. |
| 42 | */ |
Patrick Williams | d22706f | 2017-05-04 05:42:49 -0500 | [diff] [blame] | 43 | class Host : public HostInherit |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 44 | { |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 45 | public: |
| 46 | /** @brief Constructs Host State Manager |
| 47 | * |
| 48 | * @note This constructor passes 'true' to the base class in order to |
| 49 | * defer dbus object registration until we can run |
| 50 | * determineInitialState() and set our properties |
| 51 | * |
| 52 | * @param[in] bus - The Dbus bus object |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 53 | * @param[in] objPath - The Dbus object path |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 54 | * @param[in] id - The Host id |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 55 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 56 | Host(sdbusplus::bus_t& bus, const char* objPath, size_t id) : |
Patrick Williams | 7607074 | 2022-04-05 15:20:12 -0500 | [diff] [blame] | 57 | HostInherit(bus, objPath, HostInherit::action::defer_emit), bus(bus), |
Andrew Geissler | e4039a8 | 2020-02-11 15:51:59 -0600 | [diff] [blame] | 58 | systemdSignalJobRemoved( |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 59 | bus, |
| 60 | sdbusRule::type::signal() + sdbusRule::member("JobRemoved") + |
| 61 | sdbusRule::path("/org/freedesktop/systemd1") + |
| 62 | sdbusRule::interface("org.freedesktop.systemd1.Manager"), |
William A. Kennington III | bd28f02 | 2022-11-22 17:11:49 -0800 | [diff] [blame] | 63 | [this](sdbusplus::message_t& m) { sysStateChangeJobRemoved(m); }), |
Andrew Geissler | 47b9612 | 2020-02-11 16:13:13 -0600 | [diff] [blame] | 64 | systemdSignalJobNew( |
| 65 | bus, |
| 66 | sdbusRule::type::signal() + sdbusRule::member("JobNew") + |
| 67 | sdbusRule::path("/org/freedesktop/systemd1") + |
| 68 | sdbusRule::interface("org.freedesktop.systemd1.Manager"), |
William A. Kennington III | bd28f02 | 2022-11-22 17:11:49 -0800 | [diff] [blame] | 69 | [this](sdbusplus::message_t& m) { sysStateChangeJobNew(m); }), |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 70 | settings(bus, id), id(id) |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 71 | { |
| 72 | // Enable systemd signals |
Andrew Geissler | 928bbf1 | 2023-02-14 13:30:14 -0600 | [diff] [blame] | 73 | utils::subscribeToSystemdSignals(bus); |
Andrew Geissler | 4da7e00 | 2017-01-24 15:21:40 -0600 | [diff] [blame] | 74 | |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 75 | // create map of target name base on host id |
| 76 | createSystemdTargetMaps(); |
| 77 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 78 | // Will throw exception on fail |
| 79 | determineInitialState(); |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 80 | |
Andrew Geissler | 54ce639 | 2024-02-23 10:09:09 -0600 | [diff] [blame] | 81 | // Setup supported transitions against this host object |
| 82 | setupSupportedTransitions(); |
| 83 | |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 84 | // Sets auto-reboot attempts to max-allowed |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 85 | attemptsLeft(sdbusplus::server::xyz::openbmc_project::control::boot:: |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 86 | RebootAttempts::retryAttempts()); |
Dhruvaraj Subhashchandran | 2710e73 | 2017-06-19 06:43:22 -0500 | [diff] [blame] | 87 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 88 | // We deferred this until we could get our property correct |
| 89 | this->emit_object_added(); |
| 90 | } |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 91 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 92 | /** @brief Set value of HostTransition */ |
| 93 | Transition requestedHostTransition(Transition value) override; |
Andrew Geissler | ef3c184 | 2016-12-01 12:33:09 -0600 | [diff] [blame] | 94 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 95 | /** @brief Set Value for boot progress */ |
| 96 | ProgressStages bootProgress(ProgressStages value) override; |
Dhruvaraj Subhashchandran | 4e6534f | 2017-09-19 06:13:20 -0500 | [diff] [blame] | 97 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 98 | /** @brief Set Value for Operating System Status */ |
| 99 | OSStatus operatingSystemState(OSStatus value) override; |
Dhruvaraj Subhashchandran | 4e6534f | 2017-09-19 06:13:20 -0500 | [diff] [blame] | 100 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 101 | /** @brief Set value of CurrentHostState */ |
| 102 | HostState currentHostState(HostState value) override; |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 103 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 104 | /** |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 105 | * @brief Set value for allowable auto-reboot count |
| 106 | * |
| 107 | * This override is responsible for ensuring that when external users |
| 108 | * set the number of automatic retry attempts that the number of |
| 109 | * automatic reboot attempts left will update accordingly. |
| 110 | * |
| 111 | * @param[in] value - desired Reboot count value |
| 112 | * |
| 113 | * @return number of reboot attempts allowed. |
| 114 | */ |
| 115 | uint32_t retryAttempts(uint32_t value) override |
| 116 | { |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 117 | if (sdbusplus::server::xyz::openbmc_project::control::boot:: |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 118 | RebootAttempts::attemptsLeft() != value) |
| 119 | { |
| 120 | info("Automatic reboot retry attempts set to: {VALUE} ", "VALUE", |
| 121 | value); |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 122 | sdbusplus::server::xyz::openbmc_project::control::boot:: |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 123 | RebootAttempts::attemptsLeft(value); |
| 124 | } |
| 125 | |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 126 | return (sdbusplus::server::xyz::openbmc_project::control::boot:: |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 127 | RebootAttempts::retryAttempts(value)); |
| 128 | } |
| 129 | |
| 130 | /** |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 131 | * @brief Set host reboot count to default |
| 132 | * |
| 133 | * OpenBMC software controls the number of allowed reboot attempts so |
| 134 | * any external set request of this property will be overridden by |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 135 | * this function and set to the number of the allowed auto-reboot |
| 136 | * retry attempts found on the system. |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 137 | * |
| 138 | * The only code responsible for decrementing the boot count resides |
| 139 | * within this process and that will use the sub class interface |
| 140 | * directly |
| 141 | * |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 142 | * @param[in] value - Reboot count value |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 143 | * |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 144 | * @return number of reboot attempts left(allowed by retry attempts |
| 145 | * property) |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 146 | */ |
| 147 | uint32_t attemptsLeft(uint32_t value) override |
| 148 | { |
Andrew Geissler | 8ffdb26 | 2021-09-20 15:25:19 -0500 | [diff] [blame] | 149 | debug("External request to reset reboot count"); |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 150 | auto retryAttempts = sdbusplus::xyz::openbmc_project::Control::Boot:: |
| 151 | server::RebootAttempts::retryAttempts(); |
| 152 | return ( |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 153 | sdbusplus::server::xyz::openbmc_project::control::boot:: |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 154 | RebootAttempts::attemptsLeft(std::min(value, retryAttempts))); |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 155 | } |
Andrew Geissler | 7b90a62 | 2017-08-08 11:41:08 -0500 | [diff] [blame] | 156 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 157 | private: |
| 158 | /** |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 159 | * @brief Determine initial host state and set internally |
| 160 | * |
| 161 | * @return Will throw exceptions on failure |
| 162 | **/ |
| 163 | void determineInitialState(); |
Andrew Geissler | 4da7e00 | 2017-01-24 15:21:40 -0600 | [diff] [blame] | 164 | |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 165 | /** |
Andrew Geissler | 54ce639 | 2024-02-23 10:09:09 -0600 | [diff] [blame] | 166 | * @brief Configure supported transitions for system |
| 167 | * |
| 168 | * @return Will throw exceptions on failure |
| 169 | **/ |
| 170 | void setupSupportedTransitions(); |
| 171 | |
| 172 | /** |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 173 | * create systemd target instance names and mapping table |
| 174 | **/ |
| 175 | void createSystemdTargetMaps(); |
| 176 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 177 | /** @brief Execute the transition request |
| 178 | * |
| 179 | * This function assumes the state has been validated and the host |
| 180 | * is in an appropriate state for the transition to be started. |
| 181 | * |
| 182 | * @param[in] tranReq - Transition requested |
| 183 | */ |
| 184 | void executeTransition(Transition tranReq); |
Andrew Geissler | 0cd2eaf | 2016-12-07 10:50:13 -0600 | [diff] [blame] | 185 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 186 | /** |
| 187 | * @brief Determine if target is active |
| 188 | * |
| 189 | * This function determines if the target is active and |
| 190 | * helps prevent misleading log recorded states. |
| 191 | * |
| 192 | * @param[in] target - Target string to check on |
| 193 | * |
| 194 | * @return boolean corresponding to state active |
| 195 | **/ |
| 196 | bool stateActive(const std::string& target); |
Josh D. King | 929ef70 | 2017-03-02 10:58:11 -0600 | [diff] [blame] | 197 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 198 | /** |
| 199 | * @brief Determine if auto reboot flag is set |
| 200 | * |
| 201 | * @return boolean corresponding to current auto_reboot setting |
| 202 | **/ |
| 203 | bool isAutoReboot(); |
Michael Tritz | 206a833 | 2017-02-06 16:01:23 -0600 | [diff] [blame] | 204 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 205 | /** @brief Check if systemd state change is relevant to this object |
| 206 | * |
| 207 | * Instance specific interface to handle the detected systemd state |
| 208 | * change |
| 209 | * |
| 210 | * @param[in] msg - Data associated with subscribed signal |
| 211 | * |
| 212 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 213 | void sysStateChangeJobRemoved(sdbusplus::message_t& msg); |
Andrew Geissler | 4da7e00 | 2017-01-24 15:21:40 -0600 | [diff] [blame] | 214 | |
Andrew Geissler | 47b9612 | 2020-02-11 16:13:13 -0600 | [diff] [blame] | 215 | /** @brief Check if JobNew systemd signal is relevant to this object |
| 216 | * |
| 217 | * In certain instances phosphor-state-manager needs to monitor for the |
| 218 | * entry into a systemd target. This function will be used for these cases. |
| 219 | * |
| 220 | * Instance specific interface to handle the detected systemd state |
| 221 | * change |
| 222 | * |
| 223 | * @param[in] msg - Data associated with subscribed signal |
| 224 | * |
| 225 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 226 | void sysStateChangeJobNew(sdbusplus::message_t& msg); |
Andrew Geissler | 47b9612 | 2020-02-11 16:13:13 -0600 | [diff] [blame] | 227 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 228 | /** @brief Decrement reboot count |
| 229 | * |
| 230 | * This is used internally to this application to decrement the boot |
| 231 | * count on each boot attempt. The host will use the external |
| 232 | * attemptsLeft() interface to reset the count when a boot is successful |
| 233 | * |
| 234 | * @return number of reboot count attempts left |
| 235 | */ |
| 236 | uint32_t decrementRebootCount(); |
Andrew Geissler | 7b90a62 | 2017-08-08 11:41:08 -0500 | [diff] [blame] | 237 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 238 | // Allow cereal class access to allow these next two function to be |
| 239 | // private |
| 240 | friend class cereal::access; |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 241 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 242 | /** @brief Function required by Cereal to perform serialization. |
| 243 | * |
| 244 | * @tparam Archive - Cereal archive type (binary in our case). |
| 245 | * @param[in] archive - reference to Cereal archive. |
| 246 | * @param[in] version - Class version that enables handling |
| 247 | * a serialized data across code levels |
| 248 | */ |
| 249 | template <class Archive> |
| 250 | void save(Archive& archive, const std::uint32_t version) const |
| 251 | { |
Andrew Geissler | 769a62f | 2019-12-06 13:36:08 -0600 | [diff] [blame] | 252 | // version is not used currently |
| 253 | (void)(version); |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 254 | archive(sdbusplus::server::xyz::openbmc_project::control::boot:: |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 255 | RebootAttempts::retryAttempts(), |
| 256 | convertForMessage(sdbusplus::xyz::openbmc_project::State:: |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 257 | server::Host::requestedHostTransition()), |
| 258 | convertForMessage(sdbusplus::xyz::openbmc_project::State::Boot:: |
| 259 | server::Progress::bootProgress()), |
| 260 | convertForMessage( |
| 261 | sdbusplus::xyz::openbmc_project::State::OperatingSystem:: |
| 262 | server::Status::operatingSystemState())); |
| 263 | } |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 264 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 265 | /** @brief Function required by Cereal to perform deserialization. |
| 266 | * |
| 267 | * @tparam Archive - Cereal archive type (binary in our case). |
| 268 | * @param[in] archive - reference to Cereal archive. |
| 269 | * @param[in] version - Class version that enables handling |
| 270 | * a serialized data across code levels |
| 271 | */ |
| 272 | template <class Archive> |
| 273 | void load(Archive& archive, const std::uint32_t version) |
| 274 | { |
| 275 | std::string reqTranState; |
| 276 | std::string bootProgress; |
| 277 | std::string osState; |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 278 | // Older cereal archive without RetryAttempt may be implemented |
| 279 | // just set to (BOOT_COUNT_MAX_ALLOWED) |
| 280 | uint32_t retryAttempts = BOOT_COUNT_MAX_ALLOWED; |
| 281 | switch (version) |
| 282 | { |
| 283 | case 2: |
| 284 | archive(retryAttempts); |
| 285 | [[fallthrough]]; |
| 286 | case 1: |
| 287 | archive(reqTranState, bootProgress, osState); |
| 288 | break; |
| 289 | } |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 290 | auto reqTran = Host::convertTransitionFromString(reqTranState); |
| 291 | // When restoring, set the requested state with persistent value |
| 292 | // but don't call the override which would execute it |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 293 | sdbusplus::server::xyz::openbmc_project::state::Host:: |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 294 | requestedHostTransition(reqTran); |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 295 | sdbusplus::server::xyz::openbmc_project::state::boot::Progress:: |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 296 | bootProgress(Host::convertProgressStagesFromString(bootProgress)); |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 297 | sdbusplus::server::xyz::openbmc_project::state::operating_system:: |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 298 | Status::operatingSystemState( |
| 299 | Host::convertOSStatusFromString(osState)); |
Patrick Williams | 7e969cb | 2023-08-23 16:24:23 -0500 | [diff] [blame] | 300 | sdbusplus::server::xyz::openbmc_project::control::boot::RebootAttempts:: |
NodeMan97 | b4cbfac | 2022-05-09 23:56:39 -0500 | [diff] [blame] | 301 | retryAttempts(retryAttempts); |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 302 | } |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 303 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 304 | /** @brief Serialize and persist requested host state |
| 305 | * |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 306 | * @return fs::path - pathname of persisted requested host state. |
| 307 | */ |
Allen.Wang | ba182f0 | 2022-03-23 19:01:53 +0800 | [diff] [blame] | 308 | fs::path serialize(); |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 309 | |
Manojkiran Eda | 3ff5a36 | 2024-06-17 10:59:07 +0530 | [diff] [blame] | 310 | /** @brief Deserialize a persisted requested host state. |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 311 | * |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 312 | * @return bool - true if the deserialization was successful, false |
| 313 | * otherwise. |
| 314 | */ |
Allen.Wang | ba182f0 | 2022-03-23 19:01:53 +0800 | [diff] [blame] | 315 | bool deserialize(); |
Andrew Geissler | 033fc3b | 2017-08-30 15:11:44 -0500 | [diff] [blame] | 316 | |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 317 | /** |
| 318 | * @brief Get target name of a HostState |
| 319 | * |
| 320 | * @param[in] state - The state of the host |
| 321 | * |
| 322 | * @return string - systemd target name of the state |
| 323 | */ |
| 324 | const std::string& getTarget(HostState state); |
| 325 | |
| 326 | /** |
| 327 | * @brief Get target name of a TransitionRequest |
| 328 | * |
| 329 | * @param[in] tranReq - Transition requested |
| 330 | * |
| 331 | * @return string - systemd target name of Requested transition |
| 332 | */ |
| 333 | const std::string& getTarget(Transition tranReq); |
| 334 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 335 | /** @brief Persistent sdbusplus DBus bus connection. */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 336 | sdbusplus::bus_t& bus; |
Andrew Geissler | ef62116 | 2016-12-08 12:56:21 -0600 | [diff] [blame] | 337 | |
Andrew Geissler | e4039a8 | 2020-02-11 15:51:59 -0600 | [diff] [blame] | 338 | /** @brief Used to subscribe to dbus systemd JobRemoved signal **/ |
| 339 | sdbusplus::bus::match_t systemdSignalJobRemoved; |
Deepak Kodihalli | 3dd08a5 | 2017-07-25 07:34:44 -0500 | [diff] [blame] | 340 | |
Andrew Geissler | 47b9612 | 2020-02-11 16:13:13 -0600 | [diff] [blame] | 341 | /** @brief Used to subscribe to dbus systemd JobNew signal **/ |
| 342 | sdbusplus::bus::match_t systemdSignalJobNew; |
| 343 | |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 344 | // Settings host objects of interest |
| 345 | settings::HostObjects settings; |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 346 | |
| 347 | /** @brief Host id. **/ |
| 348 | const size_t id = 0; |
| 349 | |
| 350 | /** @brief HostState to systemd target mapping table. **/ |
| 351 | std::map<HostState, std::string> stateTargetTable; |
| 352 | |
| 353 | /** @brief Requested Transition to systemd target mapping table. **/ |
| 354 | std::map<Transition, std::string> transitionTargetTable; |
Andrew Geissler | 128ea8e | 2022-06-22 12:28:15 -0400 | [diff] [blame] | 355 | |
| 356 | /** @brief Target called when a host crash occurs **/ |
| 357 | std::string hostCrashTarget; |
Andrew Geissler | 3652902 | 2016-11-29 15:23:54 -0600 | [diff] [blame] | 358 | }; |
| 359 | |
| 360 | } // namespace manager |
| 361 | } // namespace state |
| 362 | } // namespace phosphor |