openbmc / x86-power-control

Apache License 2.0
12 stars 10 forks source link

OperatingSystemState property is not writable #6

Open jk-ozlabs opened 4 years ago

jk-ozlabs commented 4 years ago

x86-power-control exposes the OperatingSystem.Status interface, but can only set two values - Inactive and Standby.

The full enumeration available includes other states, but those are only (generally) determined by host firmware. In those cases, it's usually up to host firmware to update this state (typically by a Set Sensor Reading IPMI command, but any mechanism would be fine).

However, we currently export that property as readOnly (the default for register_property with only two arguments), so those other states cannot be set.

jk-ozlabs commented 4 years ago

Something like this should be sufficient:

--- a/power-control-x86/src/power_control.cpp
+++ b/power-control-x86/src/power_control.cpp
@@ -2414,7 +2414,8 @@ int main(int argc, char* argv[])
                               : "Standby";

     power_control::osIface->register_property("OperatingSystemState",
-                                              std::string(osState));
+                             std::string(osState),
+                             sdbusplus::asio::PropertyPermission::readWrite);

     power_control::osIface->initialize();

... but I'd like to first ensure that this is something we want to enable. If so, I'll submit as a proper change.