More than one event plugin can be passed to OpenSM via config file as
space separated list:

  event_plugin  name1 name2 name3

Each name will be resolved as usual - lib<nameX>.so.

Signed-off-by: Sasha Khapyorsky <[EMAIL PROTECTED]>
---

The difference against original version is "NONE" default event plugin
name removing - it is not needed anymore, but when was in use caused
segmentation fault due to constant string parsing by strtok_r().

 opensm/include/opensm/osm_event_plugin.h |   11 +++------
 opensm/include/opensm/osm_opensm.h       |    4 +-
 opensm/opensm/osm_console.c              |   13 +++++++---
 opensm/opensm/osm_event_plugin.c         |    3 +-
 opensm/opensm/osm_opensm.c               |   35 +++++++++++++++++++++++++----
 opensm/opensm/osm_subnet.c               |    5 ++-
 6 files changed, 49 insertions(+), 22 deletions(-)

diff --git a/opensm/include/opensm/osm_event_plugin.h 
b/opensm/include/opensm/osm_event_plugin.h
index a7cad32..d9e546c 100644
--- a/opensm/include/opensm/osm_event_plugin.h
+++ b/opensm/include/opensm/osm_event_plugin.h
@@ -35,8 +35,9 @@
 #define _OSM_EVENT_PLUGIN_H_
 
 #include <time.h>
-#include <opensm/osm_log.h>
 #include <iba/ib_types.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_log.h>
 
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -57,12 +58,7 @@ BEGIN_C_DECLS
 *      Ira Weiny, LLNL
 *
 *********/
-#define OSM_EVENT_PLUGIN_NAME_NONE "NONE"
-#ifdef ENABLE_OSM_DEFAULT_EVENT_PLUGIN
-#define OSM_DEFAULT_EVENT_PLUGIN_NAME "osmeventplugin"
-#else                          /* !ENABLE_OSM_DEFAULT_EVENT_PLUGIN */
-#define OSM_DEFAULT_EVENT_PLUGIN_NAME OSM_EVENT_PLUGIN_NAME_NONE
-#endif                         /* ENABLE_OSM_DEFAULT_EVENT_PLUGIN */
+
 #define OSM_EPI_NODE_NAME_LEN (128)
 /** =========================================================================
  * Event types
@@ -161,6 +157,7 @@ typedef struct osm_event_plugin {
  * The plugin structure should be considered opaque
  */
 typedef struct osm_epi_plugin {
+       cl_list_item_t list;
        void *handle;
        osm_event_plugin_t *impl;
        void *plugin_data;
diff --git a/opensm/include/opensm/osm_opensm.h 
b/opensm/include/opensm/osm_opensm.h
index 63d2247..1b758bd 100644
--- a/opensm/include/opensm/osm_opensm.h
+++ b/opensm/include/opensm/osm_opensm.h
@@ -44,6 +44,7 @@
 #define _OSM_OPENSM_H_
 
 #include <stdio.h>
+#include <complib/cl_qlist.h>
 #include <complib/cl_dispatcher.h>
 #include <complib/cl_passivelock.h>
 #include <complib/cl_atomic.h>
@@ -54,7 +55,6 @@
 #include <opensm/osm_sm.h>
 #include <opensm/osm_sa.h>
 #include <opensm/osm_perfmgr.h>
-#include <opensm/osm_event_plugin.h>
 #include <opensm/osm_db.h>
 #include <opensm/osm_subnet.h>
 #include <opensm/osm_mad_pool.h>
@@ -168,7 +168,7 @@ typedef struct _osm_opensm_t {
 #ifdef ENABLE_OSM_PERF_MGR
        osm_perfmgr_t perfmgr;
 #endif                         /* ENABLE_OSM_PERF_MGR */
-       osm_epi_plugin_t *event_plugin;
+       cl_qlist_t plugin_list;
        osm_db_t db;
        osm_mad_pool_t mad_pool;
        osm_vendor_t *p_vendor;
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index f74465e..ca4982f 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -1110,19 +1110,24 @@ static void perfmgr_parse(char **p_last, osm_opensm_t * 
p_osm, FILE * out)
                        fprintf(out, "\"%s\" option not found\n", p_cmd);
                }
        } else {
+               cl_list_item_t *item;
                fprintf(out, "Performance Manager status:\n"
                        "state                   : %s\n"
                        "sweep state             : %s\n"
                        "sweep time              : %us\n"
                        "outstanding queries/max : %d/%u\n"
-                       "loaded event plugin     : %s\n",
+                       "loaded event plugin     :",
                        osm_perfmgr_get_state_str(&(p_osm->perfmgr)),
                        osm_perfmgr_get_sweep_state_str(&(p_osm->perfmgr)),
                        osm_perfmgr_get_sweep_time_s(&(p_osm->perfmgr)),
                        p_osm->perfmgr.outstanding_queries,
-                       p_osm->perfmgr.max_outstanding_queries,
-                       p_osm->event_plugin ?
-                       p_osm->event_plugin->plugin_name : "NONE");
+                       p_osm->perfmgr.max_outstanding_queries);
+               for (item = cl_qlist_head(&p_osm->plugin_list);
+                    item != cl_qlist_end(&p_osm->plugin_list);
+                    item = cl_qlist_next(item))
+                       fprintf(out, " %s",
+                               ((osm_epi_plugin_t *)item)->plugin_name);
+               fprintf(out, "\n");
        }
 }
 #endif                         /* ENABLE_OSM_PERF_MGR */
diff --git a/opensm/opensm/osm_event_plugin.c b/opensm/opensm/osm_event_plugin.c
index 3575060..e579fad 100644
--- a/opensm/opensm/osm_event_plugin.c
+++ b/opensm/opensm/osm_event_plugin.c
@@ -63,8 +63,7 @@ osm_epi_plugin_t *osm_epi_construct(osm_log_t * p_log, char 
*plugin_name)
        char lib_name[OSM_PATH_MAX];
        osm_epi_plugin_t *rc = NULL;
 
-       if (!plugin_name ||
-           strcmp(plugin_name, OSM_EVENT_PLUGIN_NAME_NONE) == 0)
+       if (!plugin_name || !*plugin_name)
                return (NULL);
 
        /* find the plugin */
diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
index a85bcb7..adacd93 100644
--- a/opensm/opensm/osm_opensm.c
+++ b/opensm/opensm/osm_opensm.c
@@ -243,6 +243,23 @@ void osm_opensm_destroy(IN osm_opensm_t * const p_osm)
        osm_log_destroy(&p_osm->log);
 }
 
+static void load_plugins(osm_opensm_t *osm, char *plugin_names)
+{
+       osm_epi_plugin_t *epi;
+       char *name, *p;
+
+       name = strtok_r(plugin_names, " \t\n", &p);
+       while (name && *name) {
+               epi = osm_epi_construct(&osm->log, name);
+               if (!epi)
+                       osm_log(&osm->log, OSM_LOG_ERROR,
+                               "cannot load plugin \'%s\'\n", name);
+               else
+                       cl_qlist_insert_tail(&osm->plugin_list, &epi->list);
+               name = strtok_r(NULL, " \t\n", &p);
+       }
+}
+
 /**********************************************************************
  **********************************************************************/
 ib_api_status_t
@@ -348,8 +365,10 @@ osm_opensm_init(IN osm_opensm_t * const p_osm,
        if (status != IB_SUCCESS)
                goto Exit;
 
-       p_osm->event_plugin = osm_epi_construct(&p_osm->log,
-                                               p_opt->event_plugin_name);
+       cl_qlist_init(&p_osm->plugin_list);
+
+       if (p_opt->event_plugin_name)
+               load_plugins(p_osm, p_opt->event_plugin_name);
 
 #ifdef ENABLE_OSM_PERF_MGR
        status = osm_perfmgr_init(&p_osm->perfmgr, p_osm, p_opt);
@@ -406,7 +425,13 @@ Exit:
 void osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id,
                             void *event_data)
 {
-       if (osm->event_plugin && osm->event_plugin->impl->report)
-               osm->event_plugin->impl->report(osm->event_plugin->plugin_data,
-                                               event_id, event_data);
+       cl_list_item_t *item;
+
+       for (item = cl_qlist_head(&osm->plugin_list);
+            item != cl_qlist_end(&osm->plugin_list);
+            item = cl_qlist_next(item)) {
+               osm_epi_plugin_t *p = (osm_epi_plugin_t *)item;
+               if (p->impl->report)
+                       p->impl->report(p->plugin_data, event_id, event_data);
+       }
 }
diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c
index a9081c9..0341805 100644
--- a/opensm/opensm/osm_subnet.c
+++ b/opensm/opensm/osm_subnet.c
@@ -431,7 +431,7 @@ void osm_subn_set_default_opt(IN osm_subn_opt_t * const 
p_opt)
        p_opt->event_db_dump_file = NULL; /* use default */
 #endif                         /* ENABLE_OSM_PERF_MGR */
 
-       p_opt->event_plugin_name = OSM_DEFAULT_EVENT_PLUGIN_NAME;
+       p_opt->event_plugin_name = NULL;
        p_opt->node_name_map_name = NULL;
 
        p_opt->dump_files_dir = getenv("OSM_TMP_DIR");
@@ -1631,7 +1631,8 @@ int osm_subn_write_conf_file(char *file_name, IN 
osm_subn_opt_t *const p_opts)
 
        fprintf(opts_file,
                "#\n# Event Plugin Options\n#\n"
-               "event_plugin_name %s\n\n", p_opts->event_plugin_name);
+               "event_plugin_name %s\n\n", p_opts->event_plugin_name ?
+               p_opts->event_plugin_name : null_str);
 
        fprintf(opts_file,
                "#\n# Node name map for mapping node's to more descirptive node 
descriptors\n"
-- 
1.5.5.1.178.g1f811

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to