Add build option to disable daemon control via IPC
Added a build option (nlmode) to disable the attention handler runtime
control support (IPC). Until the IPC based start/stop controls are
working correctly the build will default to nlmode enabled. The
attention handler can still be stopped and started via normal systemctl
methods.
Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I8913fb441fd696d81ffc04b464601238068c3131
diff --git a/cli.cpp b/cli.cpp
index 3fcff3a..bc8b23d 100644
--- a/cli.cpp
+++ b/cli.cpp
@@ -39,43 +39,55 @@
else
{
setting = getCliSetting(i_begin, i_end, "--vital");
- if (std::string("off") == setting)
+ if (nullptr != setting)
{
- o_config->clearFlag(attn::enVital);
- }
- if (std::string("on") == setting)
- {
- o_config->setFlag(attn::enVital);
+ if (std::string("off") == setting)
+ {
+ o_config->clearFlag(attn::enVital);
+ }
+ if (std::string("on") == setting)
+ {
+ o_config->setFlag(attn::enVital);
+ }
}
setting = getCliSetting(i_begin, i_end, "--checkstop");
- if (std::string("off") == setting)
+ if (nullptr != setting)
{
- o_config->clearFlag(attn::enCheckstop);
- }
- if (std::string("on") == setting)
- {
- o_config->setFlag(attn::enCheckstop);
+ if (std::string("off") == setting)
+ {
+ o_config->clearFlag(attn::enCheckstop);
+ }
+ if (std::string("on") == setting)
+ {
+ o_config->setFlag(attn::enCheckstop);
+ }
}
setting = getCliSetting(i_begin, i_end, "--terminate");
- if (std::string("off") == setting)
+ if (nullptr != setting)
{
- o_config->clearFlag(attn::enTerminate);
- }
- if (std::string("on") == setting)
- {
- o_config->setFlag(attn::enTerminate);
+ if (std::string("off") == setting)
+ {
+ o_config->clearFlag(attn::enTerminate);
+ }
+ if (std::string("on") == setting)
+ {
+ o_config->setFlag(attn::enTerminate);
+ }
}
setting = getCliSetting(i_begin, i_end, "--breakpoints");
- if (std::string("off") == setting)
+ if (nullptr != setting)
{
- o_config->clearFlag(attn::enBreakpoints);
- }
- if (std::string("on") == setting)
- {
- o_config->setFlag(attn::enBreakpoints);
+ if (std::string("off") == setting)
+ {
+ o_config->clearFlag(attn::enBreakpoints);
+ }
+ if (std::string("on") == setting)
+ {
+ o_config->setFlag(attn::enBreakpoints);
+ }
}
}
}
diff --git a/listener.cpp b/listener.cpp
index e0640aa..e5946c4 100644
--- a/listener.cpp
+++ b/listener.cpp
@@ -39,9 +39,6 @@
{
using namespace boost::interprocess;
- // vector to hold messages sent to listener
- std::vector<std::string> messages;
-
// remove listener message queue if exists (does not throw)
message_queue::remove(mq_listener);
@@ -62,6 +59,8 @@
// originate from here via the message queue.
do
{
+ // vector to hold messages sent to listener
+ std::vector<std::string> messages;
// we will catch any exceptions from thread library
try
{
diff --git a/main_nl.cpp b/main_nl.cpp
new file mode 100644
index 0000000..2725860
--- /dev/null
+++ b/main_nl.cpp
@@ -0,0 +1,51 @@
+#include <analyzer/analyzer_main.hpp>
+#include <attn/attn_config.hpp>
+#include <attn/attn_main.hpp>
+#include <cli.hpp>
+
+/**
+ * @brief Attention handler application main()
+ *
+ * This is the main interface to the hardware diagnostics application. This
+ * application can be loaded as a daemon for monitoring the attention
+ * gpio or it can be loaded as an application to analyze hardware and
+ * diagnose hardware error conditions.
+ *
+ * Usage:
+ * --analyze: Analyze the hardware
+ * --daemon: Start the attention handler daemon
+ *
+ * @return 0 = success
+ */
+int main(int argc, char* argv[])
+{
+ int rc = 0; // assume success
+
+ if (argc == 1)
+ {
+ printf("openpower-hw-diags <options>\n");
+ printf("options:\n");
+ printf(" --analyze: Analyze the hardware\n");
+ printf(" --daemon: Start the attn handler daemon\n");
+ }
+ else
+ {
+ // Either analyze (application mode) or daemon mode
+ if (true == getCliOption(argv, argv + argc, "--analyze"))
+ {
+ analyzer::analyzeHardware();
+ }
+ // daemon mode
+ else
+ {
+ if (true == getCliOption(argv, argv + argc, "--daemon"))
+ {
+ attn::Config attnConfig; // default config
+
+ attn::attnDaemon(&attnConfig); // start daemon
+ }
+ }
+ }
+
+ return rc;
+}
diff --git a/meson.build b/meson.build
index ef2b206..32f2201 100644
--- a/meson.build
+++ b/meson.build
@@ -18,10 +18,18 @@
pthread = declare_dependency(link_args : '-pthread')
lrt = declare_dependency(link_args : '-lrt')
-executable('openpower-hw-diags', 'main.cpp', 'cli.cpp', 'listener.cpp',
- dependencies : [lrt, pthread],
- link_with : [analyzer, attn],
- install : true)
+no_listener_mode = get_option('nlmode')
+
+if not no_listener_mode.disabled()
+ executable('openpower-hw-diags', 'main_nl.cpp', 'cli.cpp',
+ link_with : [analyzer, attn],
+ install : true)
+else
+ executable('openpower-hw-diags', 'main.cpp', 'cli.cpp', 'listener.cpp',
+ dependencies : [lrt, pthread],
+ link_with : [analyzer, attn],
+ install : true)
+endif
build_tests = get_option('tests')
diff --git a/meson_options.txt b/meson_options.txt
index 0fc2767..b1c8b8f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1 +1,2 @@
option('tests', type: 'feature', description: 'Build tests')
+option('nlmode', type: 'feature', description: 'no run-time control')
diff --git a/test/simulator/chip_data/sample.cdb b/test/simulator/chip_data/sample.cdb
new file mode 100644
index 0000000..2e36af5
--- /dev/null
+++ b/test/simulator/chip_data/sample.cdb
Binary files differ