[openib-general] [PATCH] OpenSM console: Add run-time switch for console [off|local|socket]

Hal Rosenstock halr at voltaire.com
Mon Jan 15 11:30:08 PST 2007


OpenSM console: Add run-time switch for console [off|local|socket]

Signed-off-by: Ira Weiny <weiny2 at llnl.gov>
Signed-off-by: Hal Rosenstock <halr at voltaire.com>

diff --git a/osm/include/opensm/osm_subnet.h b/osm/include/opensm/osm_subnet.h
index c9b04eb..c256621 100644
--- a/osm/include/opensm/osm_subnet.h
+++ b/osm/include/opensm/osm_subnet.h
@@ -265,7 +265,7 @@ typedef struct _osm_subn_opt
   boolean_t                no_partition_enforcement;
   boolean_t                no_qos;
   boolean_t                accum_log_file;
-  boolean_t                console;
+  char *                   console;
   uint16_t                 console_port;
   cl_map_t                 port_prof_ignore_guids;
   boolean_t                port_profile_switch_nodes;
diff --git a/osm/man/opensm.8 b/osm/man/opensm.8
index e388f6d..15c1411 100644
--- a/osm/man/opensm.8
+++ b/osm/man/opensm.8
@@ -128,11 +128,13 @@ SMPs.
 Without -maxsmps, OpenSM defaults to a maximum of
 4 outstanding SMPs.
 .TP
-\fB\-console\fR
-This option brings up the OpenSM console.
+\fB\-console [off|local|socket]\fR
+This option brings up the OpenSM console (default off).
+Note that the socket option will only be available if OpenSM
+--enable-console-socket.
 .TP
 \fB\-console-port\fR <port>
-Specify an alternate telnet port for the console (default 10000).
+Specify an alternate telnet port for the socket console (default 10000).
 Note that this option only appears if OpenSM was built with
 --enable-console-socket.
 .TP
diff --git a/osm/opensm/main.c b/osm/opensm/main.c
index 8dcbfd4..ff517eb 100644
--- a/osm/opensm/main.c
+++ b/osm/opensm/main.c
@@ -228,8 +228,12 @@ show_usage(void)
           "          SMPs.\n"
           "          Without -maxsmps, OpenSM defaults to a maximum of\n"
           "          4 outstanding SMPs.\n\n" );
-  printf( "-console\n"
-          "          This option brings up the OpenSM console.\n\n" );
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+  printf( "-console [off|local|socket]\n"
+#else
+  printf( "-console [off|local]\n"
+#endif
+          "          This option activates the OpenSM console. (default off)\n\n");
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
   printf( "-console-port <port>\n"
           "          Specify an alternate telnet port for the console (default %d).\n\n",
@@ -581,7 +585,7 @@ main(
       {  "no_part_enforce",0,NULL, 'N'},
       {  "qos",           0, NULL, 'Q'},
       {  "maxsmps",       1, NULL, 'n'},
-      {  "console",       0, NULL, 'q'},
+      {  "console",       1, NULL, 'q'},
       {  "V",             0, NULL, 'V'},
       {  "help",          0, NULL, 'h'},
       {  "once",          0, NULL, 'o'},
@@ -696,8 +700,17 @@ main(
       /*
        * OpenSM interactive console
        */
-      opt.console = TRUE;
-      printf(" Enabling OpenSM interactive console\n");
+      if (strcmp(optarg, "off") == 0) {
+      	opt.console = "off";
+      } else if (strcmp(optarg, "local") == 0) {
+      	opt.console = "local";
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+      } else if (strcmp(optarg, "socket") == 0) {
+      	opt.console = "socket";
+#endif
+      } else {
+	printf("-console %s option not understood\n", optarg);
+      }
       break;
 
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
@@ -964,7 +977,7 @@ main(
       Sit here forever
     */
     while( !osm_exit_flag ) {
-      if (opt.console)
+      if (strcmp(opt.console, "off") != 0)
         osm_console(&osm);
       else
         cl_thread_suspend( 10000 );
diff --git a/osm/opensm/osm_console.c b/osm/opensm/osm_console.c
index 7b6925a..9610e21 100644
--- a/osm/opensm/osm_console.c
+++ b/osm/opensm/osm_console.c
@@ -351,7 +351,7 @@ void osm_console_init(osm_subn_opt_t *op
 {
 	p_osm->console.socket = -1;
 	/* set up the file descriptors for the console */
-    	if (opt->console) {
+    	if (strcmp(opt->console, "local") == 0) {
 		p_osm->console.in = stdin;
 		p_osm->console.out = stdout;
 		p_osm->console.in_fd = fileno(stdin);
@@ -359,7 +359,7 @@ void osm_console_init(osm_subn_opt_t *op
 
 		osm_console_prompt(p_osm->console.out);
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
-    	} else {
+    	} else if (strcmp(opt->console, "socket") == 0) {
 		struct sockaddr_in  sin;
 		int optval = 1;
 
@@ -393,7 +393,6 @@ void osm_console_init(osm_subn_opt_t *op
 		p_osm->console.out = NULL;
 		p_osm->console.in_fd = -1;
 		p_osm->console.out_fd = -1;
-    		opt->console = 1;
 		osm_log(&(p_osm->log), OSM_LOG_INFO,
 				"osm_console_init: Console listening on port %d\n", opt->console_port);
 #endif
diff --git a/osm/opensm/osm_subnet.c b/osm/opensm/osm_subnet.c
index e075091..ed1bdbb 100644
--- a/osm/opensm/osm_subnet.c
+++ b/osm/opensm/osm_subnet.c
@@ -445,7 +445,7 @@ osm_subn_set_default_opt(
   p_opt->m_key_lease_period = 0;
   p_opt->sweep_interval = OSM_DEFAULT_SWEEP_INTERVAL_SECS;
   p_opt->max_wire_smps = OSM_DEFAULT_SMP_MAX_ON_WIRE;
-  p_opt->console = FALSE;
+  p_opt->console = "off";
   p_opt->console_port = OSM_DEFAULT_CONSOLE_PORT;
   p_opt->transaction_timeout = OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC;
   /* by default we will consider waiting for 50x transaction timeout normal */
@@ -850,6 +850,10 @@ osm_subn_parse_conf_file(
         "max_wire_smps",
         p_key, p_val, &p_opts->max_wire_smps);
 
+      __osm_subn_opts_unpack_charp(
+        "console",
+        p_key, p_val, &p_opts->console);
+
       __osm_subn_opts_unpack_uint16(
         "console_port",
         p_key, p_val, &p_opts->console_port);
@@ -1268,7 +1272,9 @@ osm_subn_write_conf_file(
     "disable_multicast %s\n\n"
     "# If TRUE opensm will exit on fatal initialization issues\n"
     "exit_on_fatal %s\n\n"
-    "# Telnet port for console (default is 10000)\n"
+    "# console [off|local|socket]\n"
+    "console %s\n\n"
+    "# Telnet port for console (default %d)\n"
     "console_port %d\n\n", 
     p_opts->log_flags,
     p_opts->force_log_flush ? "TRUE" : "FALSE",
@@ -1280,7 +1286,8 @@ osm_subn_write_conf_file(
     p_opts->no_multicast_option ? "TRUE" : "FALSE",
     p_opts->disable_multicast ? "TRUE" : "FALSE",
     p_opts->exit_on_fatal ? "TRUE" : "FALSE",
-    p_opts->console_port
+    p_opts->console,
+    OSM_DEFAULT_CONSOLE_PORT, p_opts->console_port
     );
   
   fprintf(







More information about the general mailing list