host state transitioning support
The following commit has some relevant background:
https://github.com/openbmc/phosphor-dbus-interfaces/commit/9f65dfeaa5ab22cae03db45c9916868da9864f83
The new services introduced in this commit will set these new transition
states. They will work together with the existing state-manager
infrastructure in that the new services will set the transitions when
the targets start and the current software which looks for the targets
to complete will update the state to the official Running/Off.
But why not just have the existing software that monitors for the
targets to complete also monitor for them to start? This was a long and
dark hole I went down for a while. In the end, systemd D-Bus signals do
not provide enough information on target starts. The signals let you
know that "something" is going to happen to the target you're interested
in, but not the details. For example, if you start the
obmc-host-start@.target, you get two systemd notifications that indicate
"something" is going to happen to obmc-host-start@.target and also that
"something" is going to happen to obmc-host-stop@.target. This is
because when one target starts, it stops the other. Since they are both
just queued for "something" there's no mechanism to interrogate them for
which one is doing what. I tried a lot of different things here but
just couldn't get anything that covered all paths. The maintainers of
systemd have indicated on their mailing list that they are not
interested in enhancing the signal data because they feel like it would
be a rat hole of never ending data getting added to it.
Tested:
- Built into an image and verified CurrentHostState changed as expected
doing a host on, off, and reboot.
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: Id2e9bd0394fc71944d26ce4bd40b136acf82b5e4
diff --git a/service_files/meson.build b/service_files/meson.build
index 71bc72e..a1f38f9 100644
--- a/service_files/meson.build
+++ b/service_files/meson.build
@@ -10,7 +10,9 @@
'xyz.openbmc_project.State.Chassis.service',
'xyz.openbmc_project.State.Host.service',
'xyz.openbmc_project.State.ScheduledHostTransition.service',
- 'phosphor-clear-one-time@.service'
+ 'phosphor-clear-one-time@.service',
+ 'phosphor-set-host-transition-to-off@.service',
+ 'phosphor-set-host-transition-to-running@.service'
]
foreach u : unit_files
diff --git a/service_files/phosphor-set-host-transition-to-off@.service b/service_files/phosphor-set-host-transition-to-off@.service
new file mode 100644
index 0000000..0e0a594
--- /dev/null
+++ b/service_files/phosphor-set-host-transition-to-off@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Set host state to transition to off
+Wants=mapper-wait@-xyz-openbmc_project-state-host%i.service
+After=mapper-wait@-xyz-openbmc_project-state-host%i.service
+Wants=obmc-host-stop-pre@%i.target
+Before=obmc-host-stop-pre@%i.target
+
+[Service]
+Restart=no
+Type=oneshot
+ExecStart=/bin/sh -c "busctl set-property `mapper get-service /xyz/openbmc_project/state/host%i` /xyz/openbmc_project/state/host%i xyz.openbmc_project.State.Host CurrentHostState s xyz.openbmc_project.State.Host.HostState.TransitioningToOff"
+
+[Install]
+WantedBy=obmc-host-stop@%i.target
diff --git a/service_files/phosphor-set-host-transition-to-running@.service b/service_files/phosphor-set-host-transition-to-running@.service
new file mode 100644
index 0000000..69565a3
--- /dev/null
+++ b/service_files/phosphor-set-host-transition-to-running@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Set host state to transition to running
+Wants=mapper-wait@-xyz-openbmc_project-state-host%i.service
+After=mapper-wait@-xyz-openbmc_project-state-host%i.service
+Wants=obmc-host-start-pre@%i.target
+Before=obmc-host-start-pre@%i.target
+ConditionPathExists=!/run/openbmc/host@%i-on
+
+[Service]
+Restart=no
+Type=oneshot
+ExecStart=/bin/sh -c "busctl set-property `mapper get-service /xyz/openbmc_project/state/host%i` /xyz/openbmc_project/state/host%i xyz.openbmc_project.State.Host CurrentHostState s xyz.openbmc_project.State.Host.HostState.TransitioningToRunning"
+
+[Install]
+WantedBy=obmc-host-startmin@%i.target