host-restart: set restart reason on power policy use

When the power policy is the reason for a power on of the system, set
the RestartCause property appropriately.

This property is used by other software on some systems to guide
partition behaviors in the host code.

Tested:
- Set boot policy to Power.RestorePolicy.Policy.AlwaysOn and
  Power.RestorePolicy.Policy.Restore, verified RestartCause updated
  to expected value.

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: Ie3484d02e357e0b8f0c81d6abedda5b6f7d66cb5
diff --git a/discover_system_state.cpp b/discover_system_state.cpp
index 446959d..7f6855e 100644
--- a/discover_system_state.cpp
+++ b/discover_system_state.cpp
@@ -206,6 +206,9 @@
             RestorePolicy::convertPolicyFromString(powerPolicy))
         {
             info("power_policy=ALWAYS_POWER_ON, powering host on");
+            setProperty(bus, hostPath, HOST_BUSNAME, "RestartCause",
+                        convertForMessage(
+                            server::Host::RestartCause::PowerPolicyAlwaysOn));
             setProperty(bus, hostPath, HOST_BUSNAME, "RequestedHostTransition",
                         convertForMessage(server::Host::Transition::On));
         }
@@ -213,7 +216,10 @@
                  RestorePolicy::convertPolicyFromString(powerPolicy))
         {
             info("power_policy=RESTORE, restoring last state");
-
+            setProperty(
+                bus, hostPath, HOST_BUSNAME, "RestartCause",
+                convertForMessage(
+                    server::Host::RestartCause::PowerPolicyPreviousState));
             // Read last requested state and re-request it to execute it
             auto hostReqState = getProperty(bus, hostPath, HOST_BUSNAME,
                                             "RequestedHostTransition");