phosphor-ipmi-host: support multi-host settings depends
The phosphor-ipmi-host.service has hard-coded dependencies on various
dbus objects, typically exposed by phosphor-settingsd, which provide
per-host data. When built on a multi-host system, the hard-coded
dependency on 'host0' instances is incorrect.
Add support in the recipe for injecting dependencies into the service,
via the `service.d` override directory, during the bitbake 'do_install'
step so that the OBMC_HOST_INSTANCES can be evaluated and dependencies
added per-host.
Also add a variable, IPMI_HOST_NEEDED_SERVICES, which allows bbappend
on an as-needed basis to insert or remove these settings dependencies.
Fixes openbmc/openbmc#2059.
Tested: Built on Bletchley and verified the service file has
dependencies on host1-host6 instances instead of host0. Booted in QEMU
and confirmed appropriate service dependencies are functional. Built on
Witherspoon and confirmed the 'host0' dependencies are now added to the
`phosphor-ipmi-host.service.d/10-override.conf` file.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I83d873d33fd49b45c08d657c67fc71d473c25208
diff --git a/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service
index ab89831..aede5c9 100644
--- a/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service
+++ b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service
@@ -1,14 +1,5 @@
[Unit]
Description=Phosphor Inband IPMI
-# TODO openbmc/openbmc#2059 - The wants/after below should be based on providers
-Wants=mapper-wait@-xyz-openbmc_project-control-host0-boot.service
-After=mapper-wait@-xyz-openbmc_project-control-host0-boot.service
-Wants=mapper-wait@-xyz-openbmc_project-control-host0-boot-one_time.service
-After=mapper-wait@-xyz-openbmc_project-control-host0-boot-one_time.service
-Wants=mapper-wait@-xyz-openbmc_project-control-host0-power_restore_policy.service
-After=mapper-wait@-xyz-openbmc_project-control-host0-power_restore_policy.service
-Wants=mapper-wait@-xyz-openbmc_project-control-host0-restriction_mode.service
-After=mapper-wait@-xyz-openbmc_project-control-host0-restriction_mode.service
Wants=clear-once.service
After=clear-once.service
After=org.openbmc.HostIpmi.service
diff --git a/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host_git.bb b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host_git.bb
index bfc04f6..bcaf6b5 100644
--- a/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host_git.bb
+++ b/meta-phosphor/recipes-phosphor/ipmi/phosphor-ipmi-host_git.bb
@@ -97,6 +97,7 @@
FILES:${PN}:append = " ${libdir}/host-ipmid/lib*${SOLIBS}"
FILES:${PN}:append = " ${libdir}/ipmid-providers/lib*${SOLIBS}"
FILES:${PN}:append = " ${libdir}/net-ipmid/lib*${SOLIBS}"
+FILES:${PN}:append = " ${systemd_system_unitdir}/phosphor-ipmi-host.service.d/*.conf"
FILES:${PN}-dev:append = " ${libdir}/ipmid-providers/lib*${SOLIBSDEV} ${libdir}/ipmid-providers/*.la"
# Soft Power Off
@@ -137,3 +138,30 @@
# python-pyyaml-native is installed by do_configure, so put this task after
addtask merge_sensors after do_configure before do_compile
+
+IPMI_HOST_NEEDED_SERVICES = "\
+ mapper-wait@-xyz-openbmc_project-control-host{}-boot.service \
+ mapper-wait@-xyz-openbmc_project-control-host{}-boot-one_time.service \
+ mapper-wait@-xyz-openbmc_project-control-host{}-power_restore_policy.service \
+ mapper-wait@-xyz-openbmc_project-control-host{}-restriction_mode.service \
+ "
+
+do_install:append() {
+
+ # Create service override file.
+ override_dir=${D}${systemd_system_unitdir}/phosphor-ipmi-host.service.d
+ override_file=${override_dir}/10-override.conf
+ mkdir -p ${override_dir}
+ echo "[Unit]" > ${override_file}
+
+ # Insert host-instance based service dependencies.
+ for i in ${OBMC_HOST_INSTANCES};
+ do
+ for s in ${IPMI_HOST_NEEDED_SERVICES};
+ do
+ service=$(echo ${s} | sed "s/{}/${i}/g")
+ echo "Wants=${service}" >> ${override_file}
+ echo "After=${service}" >> ${override_file}
+ done
+ done
+}