Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "config.h" |
| 4 | |
| 5 | #include "settings.hpp" |
| 6 | #include "xyz/openbmc_project/State/Host/server.hpp" |
| 7 | |
| 8 | #include <sdbusplus/bus.hpp> |
| 9 | |
| 10 | namespace phosphor |
| 11 | { |
| 12 | namespace state |
| 13 | { |
| 14 | namespace manager |
| 15 | { |
| 16 | |
| 17 | using HypervisorInherit = sdbusplus::server::object::object< |
| 18 | sdbusplus::xyz::openbmc_project::State::server::Host>; |
| 19 | |
| 20 | namespace server = sdbusplus::xyz::openbmc_project::State::server; |
Andrew Geissler | c74716e | 2021-02-09 15:11:10 -0600 | [diff] [blame] | 21 | namespace sdbusRule = sdbusplus::bus::match::rules; |
Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 22 | |
| 23 | /** @class Host |
| 24 | * @brief OpenBMC host state management implementation. |
| 25 | * @details A concrete implementation for xyz.openbmc_project.State.Host |
| 26 | * DBus API. |
| 27 | */ |
| 28 | class Hypervisor : public HypervisorInherit |
| 29 | { |
| 30 | public: |
| 31 | Hypervisor() = delete; |
| 32 | Hypervisor(const Hypervisor&) = delete; |
| 33 | Hypervisor& operator=(const Hypervisor&) = delete; |
| 34 | Hypervisor(Hypervisor&&) = delete; |
| 35 | Hypervisor& operator=(Hypervisor&&) = delete; |
| 36 | virtual ~Hypervisor() = default; |
| 37 | |
| 38 | /** @brief Constructs Hypervisor State Manager |
| 39 | * |
| 40 | * @param[in] bus - The Dbus bus object |
| 41 | * @param[in] objPath - The Dbus object path |
| 42 | */ |
| 43 | Hypervisor(sdbusplus::bus::bus& bus, const char* objPath) : |
Andrew Geissler | c74716e | 2021-02-09 15:11:10 -0600 | [diff] [blame] | 44 | HypervisorInherit(bus, objPath, false), bus(bus), |
| 45 | bootProgressChangeSignal( |
| 46 | bus, |
| 47 | sdbusRule::propertiesChanged( |
| 48 | "/xyz/openbmc_project/state/host0", |
| 49 | "xyz.openbmc_project.State.Boot.Progress"), |
| 50 | std::bind(std::mem_fn(&Hypervisor::bootProgressChangeEvent), this, |
| 51 | std::placeholders::_1)) |
Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 52 | {} |
| 53 | |
| 54 | /** @brief Set value of HostTransition */ |
| 55 | server::Host::Transition |
| 56 | requestedHostTransition(server::Host::Transition value) override; |
| 57 | |
| 58 | /** @brief Set value of CurrentHostState */ |
| 59 | server::Host::HostState |
| 60 | currentHostState(server::Host::HostState value) override; |
| 61 | |
Andrew Geissler | c74716e | 2021-02-09 15:11:10 -0600 | [diff] [blame] | 62 | /** @brief Return value of CurrentHostState */ |
| 63 | server::Host::HostState currentHostState(); |
| 64 | |
| 65 | /** @brief Check if BootProgress change affects hypervisor state |
| 66 | * |
| 67 | * @param[in] bootProgress - BootProgress value to check |
| 68 | * |
| 69 | */ |
| 70 | void updateCurrentHostState(std::string& bootProgress); |
| 71 | |
Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 72 | private: |
Andrew Geissler | c74716e | 2021-02-09 15:11:10 -0600 | [diff] [blame] | 73 | /** @brief Process BootProgress property changes |
| 74 | * |
| 75 | * Instance specific interface to monitor for changes to the BootProgress |
| 76 | * property which may impact Hypervisor state. |
| 77 | * |
| 78 | * @param[in] msg - Data associated with subscribed signal |
| 79 | * |
| 80 | */ |
| 81 | void bootProgressChangeEvent(sdbusplus::message::message& msg); |
| 82 | |
Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 83 | /** @brief Persistent sdbusplus DBus bus connection. */ |
| 84 | sdbusplus::bus::bus& bus; |
Andrew Geissler | c74716e | 2021-02-09 15:11:10 -0600 | [diff] [blame] | 85 | |
| 86 | /** @brief Watch BootProgress changes to know hypervisor state **/ |
| 87 | sdbusplus::bus::match_t bootProgressChangeSignal; |
Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | } // namespace manager |
| 91 | } // namespace state |
| 92 | } // namespace phosphor |