Reset host reboot attempts on fresh boot
The host reboot attempts counter is used to ensure
the host is only allowed a certain amount of retries to
boot for any given boot request. The count should be reset,
and the host should be given it's full amount of tries, on
any fresh boot request.
This commit puts a service into the host-start target which
is only called on a fresh boot request.
Tested: Verified this new service is run on fresh boot requests
and is not run on host reboot requests.
Resolves openbmc/openbmc#3035
Change-Id: I4be327e57d6f835b19e47272ceaad796196b68c5
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/common/recipes-phosphor/state/files/phosphor-reset-host-reboot-attempts@.service b/common/recipes-phosphor/state/files/phosphor-reset-host-reboot-attempts@.service
new file mode 100644
index 0000000..35de430
--- /dev/null
+++ b/common/recipes-phosphor/state/files/phosphor-reset-host-reboot-attempts@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Reset host reboot counter
+Wants=mapper-wait@-xyz-openbmc_project-state-host%i.service
+After=mapper-wait@-xyz-openbmc_project-state-host%i.service
+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.Control.Boot.RebootAttempts AttemptsLeft u 3"
+
+[Install]
+WantedBy=obmc-host-start@%i.target
diff --git a/common/recipes-phosphor/state/phosphor-state-manager.bb b/common/recipes-phosphor/state/phosphor-state-manager.bb
index 9936156..0aefebb 100644
--- a/common/recipes-phosphor/state/phosphor-state-manager.bb
+++ b/common/recipes-phosphor/state/phosphor-state-manager.bb
@@ -54,6 +54,7 @@
FILES_${PN}-host = "${sbindir}/phosphor-host-state-manager"
DBUS_SERVICE_${PN}-host += "xyz.openbmc_project.State.Host.service"
DBUS_SERVICE_${PN}-host += "phosphor-reboot-host@.service"
+SYSTEMD_SERVICE_${PN}-host += "phosphor-reset-host-reboot-attempts@.service"
FILES_${PN}-chassis = "${sbindir}/phosphor-chassis-state-manager"
DBUS_SERVICE_${PN}-chassis += "xyz.openbmc_project.State.Chassis.service"
@@ -129,6 +130,12 @@
HOST_START_FMT = "../${HOST_STARTMIN_TMPL}:${HOST_START_TGTFMT}.requires/${HOST_STARTMIN_INSTFMT}"
SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_START_FMT', 'OBMC_HOST_INSTANCES')}"
+# Force the host-start target to call the reboot count reset service
+HOST_RST_RBT_ATTEMPTS_SVC = "phosphor-reset-host-reboot-attempts@.service"
+HOST_RST_RBT_ATTEMPTS_SVC_INST = "phosphor-reset-host-reboot-attempts@{0}.service"
+HOST_RST_RBT_ATTEMPTS_SVC_FMT = "../${HOST_RST_RBT_ATTEMPTS_SVC}:${HOST_START_TGTFMT}.requires/${HOST_RST_RBT_ATTEMPTS_SVC_INST}"
+SYSTEMD_LINK_${PN}-host += "${@compose_list_zip(d, 'HOST_RST_RBT_ATTEMPTS_SVC_FMT', 'OBMC_HOST_INSTANCES', 'OBMC_HOST_INSTANCES')}"
+
SRC_URI += "git://github.com/openbmc/phosphor-state-manager"
SRCREV = "969b2613fed44f5b504411b21a9c65d89ed28bf5"