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