host-state-manager: fix host0 failure with reading wrong object path
Assign host id into both both chassis service name and object path
Because chassis-state-manager requests two service names (with and
without id) when host id is 0, it does not need to switch back to
"xyz.openbmc_project.State.Chassis" for host0 anymore.
Tested on witherspoon qemu:
root@witherspoon:~# journalctl -u xyz.openbmc_project.State.Host@0.service
Mar 29 07:40:20 witherspoon systemd[1]: Starting Phosphor Host0 State Manager...
Mar 29 07:40:23 witherspoon phosphor-host-state-manager[396]: Check if host is running
Mar 29 07:40:23 witherspoon phosphor-host-state-manager[396]: Chassis power not on, exit
Mar 29 07:40:23 witherspoon phosphor-host-state-manager[396]: Initial Host State will be Off
Mar 29 07:40:23 witherspoon systemd[1]: Started Phosphor Host0 State Manager.
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: Ib5875f2f661c434508a4f108ae7f889532d48efc
diff --git a/host_check.cpp b/host_check.cpp
index c3bf068..f834c42 100644
--- a/host_check.cpp
+++ b/host_check.cpp
@@ -126,14 +126,8 @@
// Helper function to check if chassis power is on
bool isChassiPowerOn(sdbusplus::bus::bus& bus, size_t id)
{
- auto svcname = std::string{CHASSIS_STATE_SVC};
- auto objpath = std::string{CHASSIS_STATE_PATH};
-
- if (id != 0)
- {
- svcname += std::to_string(id);
- objpath += std::to_string(id);
- }
+ auto svcname = std::string{CHASSIS_STATE_SVC} + std::to_string(id);
+ auto objpath = std::string{CHASSIS_STATE_PATH} + std::to_string(id);
try
{