hypervisor: monitor boot progress
The BootProgress property will be tracked to set the hypervisor state as
appropriate
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I5aa5d95893222169bc5abed6b851e795f2ad5ff0
diff --git a/hypervisor_state_manager.cpp b/hypervisor_state_manager.cpp
index acfbb83..afd496a 100644
--- a/hypervisor_state_manager.cpp
+++ b/hypervisor_state_manager.cpp
@@ -46,9 +46,6 @@
return server::Host::requestedHostTransition(value);
}
-// TODO - Monitor BootProgress and update hypervisor state to Running if
-// OS is started
-
server::Host::HostState Hypervisor::currentHostState(HostState value)
{
log<level::INFO>(
@@ -57,6 +54,54 @@
return server::Host::currentHostState(value);
}
+server::Host::HostState Hypervisor::currentHostState()
+{
+ return server::Host::currentHostState();
+}
+
+void Hypervisor::updateCurrentHostState(std::string& bootProgress)
+{
+ log<level::DEBUG>(
+ fmt::format("New BootProgress: {}", bootProgress).c_str());
+
+ if (bootProgress == "xyz.openbmc_project.State.Boot.Progress."
+ "ProgressStages.SystemInitComplete")
+ {
+ currentHostState(server::Host::HostState::Standby);
+ }
+ else if (bootProgress == "xyz.openbmc_project.State.Boot.Progress."
+ "ProgressStages.OSStart")
+ {
+ currentHostState(server::Host::HostState::TransitioningToRunning);
+ }
+ else if (bootProgress == "xyz.openbmc_project.State.Boot.Progress."
+ "ProgressStages.OSRunning")
+ {
+ currentHostState(server::Host::HostState::Running);
+ }
+ else
+ {
+ // BootProgress changed and it is not one of the above so
+ // set hypervisor state to off
+ currentHostState(server::Host::HostState::Off);
+ }
+}
+
+void Hypervisor::bootProgressChangeEvent(sdbusplus::message::message& msg)
+{
+ std::string statusInterface;
+ std::map<std::string, std::variant<std::string>> msgData;
+ msg.read(statusInterface, msgData);
+
+ auto propertyMap = msgData.find("BootProgress");
+ if (propertyMap != msgData.end())
+ {
+ // Extract the BootProgress
+ auto& bootProgress = std::get<std::string>(propertyMap->second);
+ updateCurrentHostState(bootProgress);
+ }
+}
+
} // namespace manager
} // namespace state
} // namespace phosphor