Attention handler configuration file support
The default behavior of the attention handler can be overriden by
modifying the config file contents. The behavior can also be defined
by the associated build option. The default behavior remains
unchanged. The intent of this change is to allow other components to
change the attention handler behavior by updating the configuration file
and restarting the attention handler service.
Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I8f73004c926a3a070c5feb690ee5684429f922c5
diff --git a/attn/attn_config.in b/attn/attn_config.in
new file mode 100644
index 0000000..94d7842
--- /dev/null
+++ b/attn/attn_config.in
@@ -0,0 +1 @@
+CONFIG=@ATTN_CONFIG@
diff --git a/attn/attn_handler.service.in b/attn/attn_handler.service.in
index def8a00..ff31f34 100644
--- a/attn/attn_handler.service.in
+++ b/attn/attn_handler.service.in
@@ -12,7 +12,8 @@
[Service]
@ENABLE_PHAL_TRUE@Environment="PDBG_DTB=/var/lib/phosphor-software-manager/hostfw/running/DEVTREE"
-ExecStart=/usr/bin/openpower-hw-diags --daemon
+EnvironmentFile=/etc/default/attn_config
+ExecStart=/usr/bin/openpower-hw-diags --daemon $CONFIG
Restart=on-failure
[Install]
diff --git a/attn/meson.build b/attn/meson.build
index 616890f..34ec50a 100644
--- a/attn/meson.build
+++ b/attn/meson.build
@@ -6,16 +6,20 @@
# dependency to link gpiod support
libgpiod = dependency('libgpiod', version : '>=1.4.1')
-# ENABLE_PHAL_TRUE used in attn_handler.service.in
+# get openpower-hw-diags build configuration
attn_conf = configuration_data()
+# conditionally define ENABLE_PHAL_TRUE
if (get_option('phal').enabled())
attn_conf.set('ENABLE_PHAL_TRUE', '')
else
attn_conf.set('ENABLE_PHAL_TRUE', '#')
endif
-# install systemd unit file
+# attention handler default config override
+attn_conf.set('ATTN_CONFIG', get_option('attn_config'))
+
+# install attention handler unit file
configure_file(
configuration: attn_conf,
input: 'attn_handler.service.in',
@@ -25,6 +29,15 @@
dependency('systemd').get_variable(pkgconfig: 'systemdsystemunitdir')
)
+# install attention handler config file
+configure_file(
+ configuration: attn_conf,
+ input: 'attn_config.in',
+ output: 'attn_config',
+ install: true,
+ install_dir: join_paths(get_option('sysconfdir'), 'default')
+)
+
# Source files.
attn_src = files(
'attention.cpp',
diff --git a/meson_options.txt b/meson_options.txt
index 635fb07..5587317 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,7 +1,7 @@
-option('tests', type: 'feature', description: 'Build tests')
-option('nlmode', type: 'feature', description: 'no run-time control')
-
-option('phal', type: 'feature', value : 'disabled',
+option('tests', type : 'feature', description : 'Build tests')
+option('nlmode', type : 'feature', description : 'no run-time control')
+option('phal', type : 'feature', value : 'disabled',
description : '''Enable PHAL APIs for retrieving data from the POWER
Systems device tree''')
-
+option('attn_config', type : 'string', value : '',
+ description : '''Attention handler default configuration override''')