1 #include "config.h"
2 
3 #include "hypervisor_state_manager.hpp"
4 
5 #include <fmt/format.h>
6 
7 #include <phosphor-logging/elog-errors.hpp>
8 #include <phosphor-logging/log.hpp>
9 #include <sdbusplus/exception.hpp>
10 #include <sdbusplus/server.hpp>
11 
12 #include <fstream>
13 #include <iostream>
14 #include <map>
15 #include <string>
16 
17 namespace phosphor
18 {
19 namespace state
20 {
21 namespace manager
22 {
23 
24 // When you see server:: you know we're referencing our base class
25 namespace server = sdbusplus::xyz::openbmc_project::State::server;
26 using namespace phosphor::logging;
27 using sdbusplus::exception::SdBusError;
28 
29 server::Host::Transition Hypervisor::requestedHostTransition(Transition value)
30 {
31     log<level::INFO>(fmt::format("Hypervisor state transition request of {}",
32                                  convertForMessage(value))
33                          .c_str());
34 
35     // Only support the transition to On
36     if (value != server::Host::Transition::On)
37     {
38         log<level::ERR>("Hypervisor state only supports a transition to On");
39         // TODO raise appropriate error exception
40         return server::Host::Transition::Off;
41     }
42 
43     // This property is monitored by a separate application (for example PLDM)
44     // which is responsible for propagating the On request to the hypervisor
45 
46     return server::Host::requestedHostTransition(value);
47 }
48 
49 // TODO - Monitor BootProgress and update hypervisor state to Running if
50 //        OS is started
51 
52 server::Host::HostState Hypervisor::currentHostState(HostState value)
53 {
54     log<level::INFO>(
55         fmt::format("Change to Hypervisor State: {}", convertForMessage(value))
56             .c_str());
57     return server::Host::currentHostState(value);
58 }
59 
60 } // namespace manager
61 } // namespace state
62 } // namespace phosphor
63