]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[OPENSM] When running as a service, if all ports are down, use the first port.
authorsleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 31 Aug 2006 08:08:18 +0000 (08:08 +0000)
committersleybo <sleybo@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Thu, 31 Aug 2006 08:08:18 +0000 (08:08 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@472 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/ulp/opensm/user/opensm/main.c

index f688f0670b15f24282c65d5496fcc75e7cf11b0e..f53d957bf07b21cc5a926fccb4cf6d94bde57749 100644 (file)
@@ -28,7 +28,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  *
- * $Id: main.c 3445 2005-09-15 08:35:44Z yael $
+ * $Id: main.c 1632 2006-08-29 09:01:07Z tzachid $
  */
 
 
@@ -75,7 +75,8 @@ HANDLE osm_exit_event = NULL;
 typedef struct _osm_main_args_t
 {
   int                   argc;
-  char**                 argv;
+  char**                argv;
+  boolean_t             is_service;
 } osm_main_args_t;
 
 osm_main_args_t osm_main_args;
@@ -302,7 +303,8 @@ show_menu(void)
  **********************************************************************/
 ib_net64_t
 get_port_guid(
-  IN osm_opensm_t *p_osm, uint64_t port_guid )
+  IN osm_opensm_t *p_osm, uint64_t port_guid,
+  IN boolean_t is_service)
 {
   uint32_t i;
   uint32_t choice = 0;
@@ -358,6 +360,11 @@ get_port_guid(
         return( attr_array[i].port_guid );
       }
     }
+    /* If we are running as a service, and all ports are doen we return the 
+       first port (we can't open a window, as a service)*/
+       if (is_service) {
+         return( attr_array[0].port_guid );
+       }
   }
 
   /* More than one possible port - list all ports and let the user to choose. */
@@ -803,6 +810,7 @@ opensm_main(
   status = osm_opensm_init( &osm, &opt );
   if( status != IB_SUCCESS )
   {
+    char      buffer[LOG_ENTRY_SIZE_MAX];
     const char *err_str = ib_get_err_str( status );
     if (err_str == NULL)
     {
@@ -810,8 +818,11 @@ opensm_main(
     }
     printf( "\nError from osm_opensm_init: %s.\n",
             err_str);
+    sprintf(buffer, "Error from osm_opensm_init: %s. See opensm log file for more details", err_str);
     /* We will just exit, and not go to Exit, since we don't
        want the destroy to be called. */
+    cl_log_event("OpenSM", LOG_ERR, buffer , NULL, 0);
+    g_service_state = SERVICE_STATE_START_FAILED;
     return( status );
   }
 
@@ -820,7 +831,7 @@ opensm_main(
     then get a port GUID value with which to bind.
   */
   if( opt.guid == 0 || cl_hton64(opt.guid) == CL_HTON64(INVALID_GUID))
-    opt.guid = get_port_guid( &osm, opt.guid );
+    opt.guid = get_port_guid( &osm, opt.guid, ((osm_main_args_t*)osm_main_args)->is_service );
 
   if ( opt.guid == 0 )
   {
@@ -933,6 +944,7 @@ main (
     if (!strcmp(argv[i], "--service"))
     {
       run_as_service = TRUE;
+      osm_main_args.is_service = TRUE;
       break;
     }
     osm_exit_event = CreateEvent(NULL, FALSE, FALSE, NULL);
@@ -945,6 +957,7 @@ main (
   if (!run_as_service)
   {
     /* Running as executable */
+    osm_main_args.is_service = FALSE;
     return opensm_main(&osm_main_args);
   }
   else