OpenPOWER: Clear system and resource dump entries while powering off
The dumps like system and resource dumps are stored in host memory
and that will be lost during a power off, so the entries in BMC
dump-manager for those dumps will be stale after a power off.
This commit adds a service to call deleteAll to clear the entries
for system and resource dumps during system power off.
Tests:
1 - Created a resource dump and system dump
and activated the service
Result: Both dump entries are cleared
2 - Created a resource dump and system dump
powered off the system
Result: Both dump entries are cleared
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
Change-Id: I4e6a59ae852c86f5edbab767fb6a0ff2a4635289
diff --git a/dump-extensions/openpower-dumps/clear_hostdumps_poweroff.service b/dump-extensions/openpower-dumps/clear_hostdumps_poweroff.service
new file mode 100644
index 0000000..3673c84
--- /dev/null
+++ b/dump-extensions/openpower-dumps/clear_hostdumps_poweroff.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Remove entries of dumps stored in the host memory during poweroff
+Wants=obmc-host-stop-pre@0.target
+After=obmc-host-stop-pre@0.target
+Wants=obmc-host-stopping@0.target
+Before=obmc-host-stopping@0.target
+Conflicts=obmc-host-startmin@0.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/busctl call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/resource xyz.openbmc_project.Collection.DeleteAll DeleteAll
+ExecStart=/usr/bin/busctl call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/system xyz.openbmc_project.Collection.DeleteAll DeleteAll
+RemainAfterExit=yes
+
+[Install]
+WantedBy=obmc-host-stop@0.target
diff --git a/dump-extensions/openpower-dumps/meson.build b/dump-extensions/openpower-dumps/meson.build
index f2e3c23..abb9904 100644
--- a/dump-extensions/openpower-dumps/meson.build
+++ b/dump-extensions/openpower-dumps/meson.build
@@ -1,5 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
+unit_files += {'input': 'dump-extensions/openpower-dumps/clear_hostdumps_poweroff.service',
+ 'output': 'clear_hostdumps_poweroff.service'}
+
# Configuration header file(openpower_dumps_config.h) generation
opconf_data = configuration_data()
diff --git a/meson.build b/meson.build
index d7b5714..3566a89 100644
--- a/meson.build
+++ b/meson.build
@@ -15,6 +15,11 @@
cpp = meson.get_compiler('cpp')
+# list of unit files, the path as input and service name
+# as output
+# eg: unit_file += {'input:'<path>, 'output':<service name>}
+unit_files = []
+
# Checking dependency external library
libsystemd = dependency('libsystemd', version : '>=221')
@@ -251,6 +256,21 @@
)
endforeach
+unit_subs = configuration_data()
+unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
+systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable(
+ 'systemdsystemunitdir',
+ define_variable: ['prefix', get_option('prefix')])
+foreach u : unit_files
+ configure_file(
+ configuration: unit_subs,
+ input: u.get('input'),
+ install: true,
+ install_dir: systemd_system_unit_dir,
+ output: u.get('output')
+ )
+endforeach
+
if get_option('tests').enabled()
subdir('test')
endif