From 42ecffb6d0b3fcb085913286398ab40ae6e8f06e Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Sat, 7 May 2016 04:12:01 -0700 Subject: [PATCH] Move the registration of MCA params out of the init of the var system - put them in with the rest of the OPAL MCA param registrations Take another shot at untangling the spaghetti orterun: fix for command line parsing orte-submit calls opal_init_util () before parsing out MCA command line options (-mca, -am, etc). This prevents mpirun from setting opal MCA variables for some frameworks as well as the MCA base. This is because when a framework is opened all of its variables are set to read-only. Eventually we want to lift this restriction on some MCA variables but since -mca is affected we must parse out the MCA command line options before opal_init_util(). This commit fixes the bug by adding a new option to opal_cmd_line_parse (ignore unknown option) so orte-submit can pre-parse the command line for MCA options. Signed-off-by: Nathan Hjelm Minor cleanups to avoid releasing/recreating the cmd line --- opal/mca/base/mca_base_parse_paramfile.c | 2 +- opal/mca/base/mca_base_var.c | 59 +++++--------------- opal/mca/base/mca_base_var.h | 11 ++++ opal/runtime/opal_info_support.c | 6 +- opal/runtime/opal_init.c | 8 +++ opal/runtime/opal_params.c | 40 ++++++++++++- opal/tools/opal-checkpoint/opal-checkpoint.c | 4 +- opal/tools/opal-restart/opal-restart.c | 4 +- opal/util/cmd_line.c | 11 ++-- opal/util/cmd_line.h | 6 ++ orte/orted/orted_main.c | 5 +- orte/orted/orted_submit.c | 56 +++++++++++-------- orte/tools/orte-checkpoint/orte-checkpoint.c | 5 +- orte/tools/orte-clean/orte-clean.c | 5 +- orte/tools/orte-dvm/orte-dvm.c | 8 +-- orte/tools/orte-info/orte-info.c | 5 +- orte/tools/orte-migrate/orte-migrate.c | 5 +- orte/tools/orte-ps/orte-ps.c | 5 +- orte/tools/orte-restart/orte-restart.c | 5 +- orte/tools/orte-server/orte-server.c | 5 +- orte/tools/orte-top/orte-top.c | 5 +- 21 files changed, 157 insertions(+), 103 deletions(-) diff --git a/opal/mca/base/mca_base_parse_paramfile.c b/opal/mca/base/mca_base_parse_paramfile.c index 80ea86e1d5c..db19d143a2d 100644 --- a/opal/mca/base/mca_base_parse_paramfile.c +++ b/opal/mca/base/mca_base_parse_paramfile.c @@ -29,7 +29,7 @@ #include "opal/mca/base/base.h" #include "opal/mca/base/mca_base_vari.h" #include "opal/util/keyval_parse.h" - +#include "opal/util/output.h" static void save_value(const char *name, const char *value); static char * file_being_read; diff --git a/opal/mca/base/mca_base_var.c b/opal/mca/base/mca_base_var.c index 5ba235b172d..6cabcc52427 100644 --- a/opal/mca/base/mca_base_var.c +++ b/opal/mca/base/mca_base_var.c @@ -66,10 +66,9 @@ static char *mca_base_var_override_file = NULL; static char *mca_base_var_file_prefix = NULL; static char *mca_base_envar_file_prefix = NULL; static char *mca_base_param_file_path = NULL; -static char *mca_base_env_list = NULL; -#define MCA_BASE_ENV_LIST_SEP_DEFAULT ";" -static char *mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT; -static char *mca_base_env_list_internal = NULL; +char *mca_base_env_list = NULL; +char *mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT; +char *mca_base_env_list_internal = NULL; static bool mca_base_var_suppress_override_warning = false; static opal_list_t mca_base_var_file_values; static opal_list_t mca_base_envar_file_values; @@ -130,7 +129,6 @@ static const char *info_lvl_strings[] = { */ static int fixup_files(char **file_list, char * path, bool rel_path_search, char sep); static int read_files (char *file_list, opal_list_t *file_values, char sep); -static int mca_base_var_cache_files (bool rel_path_search); static int var_set_initial (mca_base_var_t *var, mca_base_var_t *original); static int var_get (int vari, mca_base_var_t **var_out, bool original); static int var_value_string (mca_base_var_t *var, char **value_string); @@ -242,7 +240,6 @@ static char *append_filename_to_list(const char *filename) int mca_base_var_init(void) { int ret; - char *name = NULL; if (!mca_base_var_initialized) { /* Init the value array for the param storage */ @@ -282,41 +279,6 @@ int mca_base_var_init(void) mca_base_var_initialized = true; - mca_base_var_cache_files(false); - - /* register the envar-forwarding params */ - (void)mca_base_var_register ("opal", "mca", "base", "env_list", - "Set SHELL env variables", - MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, - MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list); - - mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT; - (void)mca_base_var_register ("opal", "mca", "base", "env_list_delimiter", - "Set SHELL env variables delimiter. Default: semicolon ';'", - MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, - MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_sep); - - /* Set OMPI_MCA_mca_base_env_list variable, it might not be set before - * if mca variable was taken from amca conf file. Need to set it - * here because mca_base_var_process_env_list is called from schizo_ompi.c - * only when this env variable was set. - */ - if (NULL != mca_base_env_list) { - (void) mca_base_var_env_name ("mca_base_env_list", &name); - if (NULL != name) { - opal_setenv(name, mca_base_env_list, false, &environ); - free(name); - } - } - - /* Register internal MCA variable mca_base_env_list_internal. It can be set only during - * parsing of amca conf file and contains SHELL env variables specified via -x there. - * Its format is the same as for mca_base_env_list. - */ - (void)mca_base_var_register ("opal", "mca", "base", "env_list_internal", - "Store SHELL env variables from amca conf file", - MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_INTERNAL, OPAL_INFO_LVL_3, - MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_internal); } return OPAL_SUCCESS; @@ -419,7 +381,7 @@ static void resolve_relative_paths(char **file_prefix, char *file_path, bool rel } } -static int mca_base_var_cache_files(bool rel_path_search) +int mca_base_var_cache_files(bool rel_path_search) { char *tmp; int ret; @@ -427,7 +389,7 @@ static int mca_base_var_cache_files(bool rel_path_search) /* We may need this later */ home = (char*)opal_home_directory(); - if(NULL == cwd) { + if (NULL == cwd) { cwd = (char *) malloc(sizeof(char) * MAXPATHLEN); if( NULL == (cwd = getcwd(cwd, MAXPATHLEN) )) { opal_output(0, "Error: Unable to get the current working directory\n"); @@ -452,7 +414,8 @@ static int mca_base_var_cache_files(bool rel_path_search) MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_2, MCA_BASE_VAR_SCOPE_READONLY, &mca_base_var_files); free (tmp); - if (OPAL_SUCCESS != ret) { + if (0 > ret) { + opal_output(0, "FAILED PARAM FILES: %d", ret); return ret; } @@ -464,6 +427,7 @@ static int mca_base_var_cache_files(bool rel_path_search) ret = asprintf(&mca_base_var_override_file, "%s" OPAL_PATH_SEP "openmpi-mca-params-override.conf", opal_install_dirs.sysconfdir); if (0 > ret) { + opal_output(0, "FAILED OVERRIDE"); return OPAL_ERR_OUT_OF_RESOURCE; } @@ -476,6 +440,7 @@ static int mca_base_var_cache_files(bool rel_path_search) &mca_base_var_override_file); free (tmp); if (0 > ret) { + opal_output(0, "FAILED OVERRIDE PARAM FILES"); return ret; } @@ -490,6 +455,7 @@ static int mca_base_var_cache_files(bool rel_path_search) MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0, OPAL_INFO_LVL_2, MCA_BASE_VAR_SCOPE_LOCAL, &mca_base_var_suppress_override_warning); if (0 > ret) { + opal_output(0, "FAILED OVERRIDE WARNING"); return ret; } @@ -503,6 +469,7 @@ static int mca_base_var_cache_files(bool rel_path_search) MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_READONLY, &mca_base_var_file_prefix); if (0 > ret) { + opal_output(0, "FAILED PARAM PREFIX"); return ret; } @@ -512,12 +479,14 @@ static int mca_base_var_cache_files(bool rel_path_search) MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_READONLY, &mca_base_envar_file_prefix); if (0 > ret) { + opal_output(0, "FAILED ENV PREFIX"); return ret; } ret = asprintf(&mca_base_param_file_path, "%s" OPAL_PATH_SEP "amca-param-sets%c%s", opal_install_dirs.opaldatadir, OPAL_ENV_SEP, cwd); if (0 > ret) { + opal_output(0, "FAILED PARAM FILE PATH"); return OPAL_ERR_OUT_OF_RESOURCE; } @@ -528,6 +497,7 @@ static int mca_base_var_cache_files(bool rel_path_search) MCA_BASE_VAR_SCOPE_READONLY, &mca_base_param_file_path); free (tmp); if (0 > ret) { + opal_output(0, "FAILED PARAM FILE PATH2"); return ret; } @@ -537,6 +507,7 @@ static int mca_base_var_cache_files(bool rel_path_search) MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_READONLY, &force_agg_path); if (0 > ret) { + opal_output(0, "FAILED PARAM FILE FORCE"); return ret; } diff --git a/opal/mca/base/mca_base_var.h b/opal/mca/base/mca_base_var.h index efca95c3c02..bfff44bf1f8 100644 --- a/opal/mca/base/mca_base_var.h +++ b/opal/mca/base/mca_base_var.h @@ -733,6 +733,17 @@ OPAL_DECLSPEC int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_typ OPAL_DECLSPEC int mca_base_var_process_env_list(char *list, char ***argv); OPAL_DECLSPEC int mca_base_var_process_env_list_from_file(char ***argv); +/* + * Initialize any file-based params + */ +OPAL_DECLSPEC int mca_base_var_cache_files(bool rel_path_search); + + +extern char *mca_base_env_list; +#define MCA_BASE_ENV_LIST_SEP_DEFAULT ";" +extern char *mca_base_env_list_sep; +extern char *mca_base_env_list_internal; + END_C_DECLS #endif /* OPAL_MCA_BASE_VAR_H */ diff --git a/opal/runtime/opal_info_support.c b/opal/runtime/opal_info_support.c index 3f4694ce27e..6d0070c9db1 100644 --- a/opal/runtime/opal_info_support.c +++ b/opal/runtime/opal_info_support.c @@ -11,8 +11,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2010-2015 Los Alamos National Security, LLC. - * All rights reserved. + * Copyright (c) 2010-2016 Los Alamos National Security, LLC. All rights + * reserved. * Copyright (c) 2011-2012 University of Houston. All rights reserved. * $COPYRIGHT$ * @@ -174,7 +174,7 @@ int opal_info_init(int argc, char **argv, } /* Do the parsing */ - ret = opal_cmd_line_parse(opal_info_cmd_line, false, argc, argv); + ret = opal_cmd_line_parse(opal_info_cmd_line, false, false, argc, argv); if (OPAL_SUCCESS != ret) { cmd_error = true; if (OPAL_ERR_SILENT != ret) { diff --git a/opal/runtime/opal_init.c b/opal/runtime/opal_init.c index 34a850d1562..a6f97990a8f 100644 --- a/opal/runtime/opal_init.c +++ b/opal/runtime/opal_init.c @@ -40,6 +40,7 @@ #include "opal/util/proc.h" #include "opal/memoryhooks/memory.h" #include "opal/mca/base/base.h" +#include "opal/mca/base/mca_base_var.h" #include "opal/runtime/opal.h" #include "opal/util/net.h" #include "opal/datatype/opal_datatype.h" @@ -414,6 +415,13 @@ opal_init(int* pargc, char*** pargv) return ret; } + /* read any param files that were provided */ + if (OPAL_SUCCESS != (ret = mca_base_var_cache_files(false))) { + error = "failed to cache files"; + goto return_error; + } + + /* open hwloc - since this is a static framework, no * select is required */ diff --git a/opal/runtime/opal_params.c b/opal/runtime/opal_params.c index 83873e90a0f..0292e1c4c7c 100644 --- a/opal/runtime/opal_params.c +++ b/opal/runtime/opal_params.c @@ -43,6 +43,7 @@ #include "opal/mca/base/mca_base_var.h" #include "opal/runtime/opal_params.h" #include "opal/dss/dss.h" +#include "opal/util/opal_environ.h" #include "opal/util/show_help.h" #include "opal/util/timings.h" @@ -292,7 +293,7 @@ int opal_register_params(void) MCA_BASE_VAR_SCOPE_READONLY, &opal_abort_delay); if (0 > ret) { - return ret; + return ret; } opal_abort_print_stack = false; @@ -313,9 +314,44 @@ int opal_register_params(void) #endif &opal_abort_print_stack); if (0 > ret) { - return ret; + return ret; + } + + /* register the envar-forwarding params */ + (void)mca_base_var_register ("opal", "mca", "base", "env_list", + "Set SHELL env variables", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list); + + mca_base_env_list_sep = MCA_BASE_ENV_LIST_SEP_DEFAULT; + (void)mca_base_var_register ("opal", "mca", "base", "env_list_delimiter", + "Set SHELL env variables delimiter. Default: semicolon ';'", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_sep); + + /* Set OMPI_MCA_mca_base_env_list variable, it might not be set before + * if mca variable was taken from amca conf file. Need to set it + * here because mca_base_var_process_env_list is called from schizo_ompi.c + * only when this env variable was set. + */ + if (NULL != mca_base_env_list) { + char *name = NULL; + (void) mca_base_var_env_name ("mca_base_env_list", &name); + if (NULL != name) { + opal_setenv(name, mca_base_env_list, false, &environ); + free(name); + } } + /* Register internal MCA variable mca_base_env_list_internal. It can be set only during + * parsing of amca conf file and contains SHELL env variables specified via -x there. + * Its format is the same as for mca_base_env_list. + */ + (void)mca_base_var_register ("opal", "mca", "base", "env_list_internal", + "Store SHELL env variables from amca conf file", + MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_INTERNAL, OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_READONLY, &mca_base_env_list_internal); + /* The ddt engine has a few parameters */ ret = opal_datatype_register_params(); if (OPAL_SUCCESS != ret) { diff --git a/opal/tools/opal-checkpoint/opal-checkpoint.c b/opal/tools/opal-checkpoint/opal-checkpoint.c index 4cef950d9ce..a472f4685b4 100644 --- a/opal/tools/opal-checkpoint/opal-checkpoint.c +++ b/opal/tools/opal-checkpoint/opal-checkpoint.c @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ @@ -283,7 +283,7 @@ static int parse_args(int argc, char *argv[]) { opal_cmd_line_create(&cmd_line, cmd_line_opts); mca_base_open(); mca_base_cmd_line_setup(&cmd_line); - ret = opal_cmd_line_parse(&cmd_line, true, argc, argv); + ret = opal_cmd_line_parse(&cmd_line, true, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { diff --git a/opal/tools/opal-restart/opal-restart.c b/opal/tools/opal-restart/opal-restart.c index cb8374b01ca..7f9dfc042a3 100644 --- a/opal/tools/opal-restart/opal-restart.c +++ b/opal/tools/opal-restart/opal-restart.c @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2007 Evergrid, Inc. All rights reserved. * Copyright (c) 2011 Oak Ridge National Labs. All rights reserved. @@ -522,7 +522,7 @@ static int parse_args(int argc, char *argv[]) mca_base_open(); mca_base_cmd_line_setup(&cmd_line); - ret = opal_cmd_line_parse(&cmd_line, false, argc, argv); + ret = opal_cmd_line_parse(&cmd_line, false, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { fprintf(stderr, "%s: command line error (%s)\n", argv[0], diff --git a/opal/util/cmd_line.c b/opal/util/cmd_line.c index 059bc38fa9b..bac3430344c 100644 --- a/opal/util/cmd_line.c +++ b/opal/util/cmd_line.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,8 +10,8 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2012 Los Alamos National Security, LLC. - * All rights reserved. + * Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights + * reserved. * Copyright (c) 2012-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. @@ -239,7 +240,7 @@ int opal_cmd_line_make_opt3(opal_cmd_line_t *cmd, char short_name, * Parse a command line according to a pre-built OPAL command line * handle. */ -int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown, +int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown, bool ignore_unknown_option, int argc, char **argv) { int i, j, orig, ret; @@ -345,7 +346,7 @@ int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown, if (NULL != option) { opal_argv_delete(&cmd->lcl_argc, - &cmd->lcl_argv, i, + &cmd->lcl_argv, i, 1 + num_args_used); opal_argv_insert(&cmd->lcl_argv, i, shortsv); cmd->lcl_argc = opal_argv_count(cmd->lcl_argv); @@ -476,7 +477,7 @@ int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown, into the tail. If we're not ignoring unknowns, then print an error and return. */ if (is_unknown_option || is_unknown_token) { - if (!ignore_unknown || is_unknown_option) { + if (!ignore_unknown || (is_unknown_option && !ignore_unknown_option)) { fprintf(stderr, "%s: Error: unknown option \"%s\"\n", cmd->lcl_argv[0], cmd->lcl_argv[i]); printed_error = true; diff --git a/opal/util/cmd_line.h b/opal/util/cmd_line.h index a374899b497..d42c5551956 100644 --- a/opal/util/cmd_line.h +++ b/opal/util/cmd_line.h @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology @@ -11,6 +12,8 @@ * All rights reserved. * Copyright (c) 2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2016 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -332,6 +335,8 @@ BEGIN_C_DECLS * @param cmd OPAL command line handle. * @param ignore_unknown Whether to print an error message upon * finding an unknown token or not + * @param ignore_unknown_option Whether to print an error message upon + * finding an unknown option or not * @param argc Length of the argv array. * @param argv Array of strings from the command line. * @@ -414,6 +419,7 @@ BEGIN_C_DECLS */ OPAL_DECLSPEC int opal_cmd_line_parse(opal_cmd_line_t *cmd, bool ignore_unknown, + bool ignore_unknown_option, int argc, char **argv); /** diff --git a/orte/orted/orted_main.c b/orte/orted/orted_main.c index 3ced75ff216..d975e7d9d6c 100644 --- a/orte/orted/orted_main.c +++ b/orte/orted/orted_main.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2009 Institut National de Recherche en Informatique * et Automatique. All rights reserved. @@ -249,7 +250,7 @@ int orte_daemon(int argc, char *argv[]) exit(1); } mca_base_cmd_line_setup(cmd_line); - if (ORTE_SUCCESS != (ret = opal_cmd_line_parse(cmd_line, false, + if (ORTE_SUCCESS != (ret = opal_cmd_line_parse(cmd_line, false, false, argc, argv))) { char *args = NULL; args = opal_cmd_line_get_usage_msg(cmd_line); diff --git a/orte/orted/orted_submit.c b/orte/orted/orted_submit.c index 4c440ec298c..41d3bf1d161 100644 --- a/orte/orted/orted_submit.c +++ b/orte/orted/orted_submit.c @@ -1,5 +1,5 @@ -/* -*- C -*- - * +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2016 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science @@ -114,7 +114,6 @@ static char **global_mca_env = NULL; static orte_std_cntr_t total_num_apps = 0; static bool want_prefix_by_default = (bool) ORTE_WANT_ORTERUN_PREFIX_BY_DEFAULT; static opal_pointer_array_t tool_jobs; -static bool mycmdline = false; int orte_debugger_attach_fd = -1; bool orte_debugger_fifo_active=false; opal_event_t *orte_debugger_attach=NULL; @@ -238,6 +237,25 @@ int orte_submit_init(int argc, char *argv[], } } + /* need to parse mca options *before* opal_init_util() */ + orte_cmd_line = OBJ_NEW(opal_cmd_line_t); + mca_base_cmd_line_setup (orte_cmd_line); + + /* parse the result to get values */ + if (OPAL_SUCCESS != (rc = opal_cmd_line_parse(orte_cmd_line, + true, true, argc, argv)) ) { + if (OPAL_ERR_SILENT != rc) { + fprintf(stderr, "%s: command line error (%s)\n", argv[0], + opal_strerror(rc)); + } + return rc; + } + + if (OPAL_SUCCESS != (rc = mca_base_cmd_line_process_args(orte_cmd_line, &environ, &environ))) { + return rc; + } + + /* init only the util portion of OPAL */ if (OPAL_SUCCESS != (rc = opal_init_util(&argc, &argv))) { return rc; @@ -255,24 +273,16 @@ int orte_submit_init(int argc, char *argv[], OBJ_CONSTRUCT(&tool_jobs, opal_pointer_array_t); opal_pointer_array_init(&tool_jobs, 256, INT_MAX, 128); - /* setup the cmd line only once */ + /* if they were provided, add the opts */ if (NULL != opts) { - /* just add the component-defined ones to the end */ - if (OPAL_SUCCESS != (rc = orte_schizo.define_cli(opts))) { + if (OPAL_SUCCESS != (rc = opal_cmd_line_add(orte_cmd_line, opts))) { return rc; } - orte_cmd_line = opts; - mycmdline = false; - } else { + } - /* have to create the cmd line next as even --help - * will need it */ - orte_cmd_line = OBJ_NEW(opal_cmd_line_t); - if (OPAL_SUCCESS != (rc = orte_schizo.define_cli(orte_cmd_line))) { - OBJ_RELEASE(orte_cmd_line); - return rc; - } - mycmdline = true; + /* setup the rest of the cmd line only once */ + if (OPAL_SUCCESS != (rc = orte_schizo.define_cli(orte_cmd_line))) { + return rc; } /* now that options have been defined, finish setup */ @@ -280,7 +290,7 @@ int orte_submit_init(int argc, char *argv[], /* parse the result to get values */ if (OPAL_SUCCESS != (rc = opal_cmd_line_parse(orte_cmd_line, - true, argc, argv)) ) { + true, false, argc, argv)) ) { if (OPAL_ERR_SILENT != rc) { fprintf(stderr, "%s: command line error (%s)\n", argv[0], opal_strerror(rc)); @@ -300,7 +310,7 @@ int orte_submit_init(int argc, char *argv[], /* show_help is not yet available, so print an error manually */ fprintf(stderr, "%s has detected an attempt to run as root.\n", orte_basename); } - fprintf(stderr, "Running at root is *strongly* discouraged as any mistake (e.g., in\n"); + fprintf(stderr, "Running as root is *strongly* discouraged as any mistake (e.g., in\n"); fprintf(stderr, "defining TMPDIR) or bug can result in catastrophic damage to the OS\n"); fprintf(stderr, "file system, leaving your system in an unusable state.\n\n"); fprintf(stderr, "You can override this protection by adding the --allow-run-as-root\n"); @@ -575,7 +585,7 @@ void orte_submit_finalize(void) OBJ_DESTRUCT(&tool_jobs); /* destruct the cmd line object */ - if (mycmdline) { + if (NULL != orte_cmd_line) { OBJ_RELEASE(orte_cmd_line); } @@ -681,7 +691,7 @@ int orte_submit_job(char *argv[], int *index, /* parse the cmd line - do this every time thru so we can * repopulate the globals */ - if (OPAL_SUCCESS != (rc = opal_cmd_line_parse(orte_cmd_line, true, + if (OPAL_SUCCESS != (rc = opal_cmd_line_parse(orte_cmd_line, true, false, argc, argv)) ) { if (OPAL_ERR_SILENT != rc) { fprintf(stderr, "%s: command line error (%s)\n", argv[0], @@ -1256,7 +1266,7 @@ static int create_app(int argc, char* argv[], init_globals(); /* parse the cmd line - do this every time thru so we can * repopulate the globals */ - if (OPAL_SUCCESS != (rc = opal_cmd_line_parse(orte_cmd_line, true, + if (OPAL_SUCCESS != (rc = opal_cmd_line_parse(orte_cmd_line, true, false, argc, argv)) ) { if (OPAL_ERR_SILENT != rc) { fprintf(stderr, "%s: command line error (%s)\n", argv[0], diff --git a/orte/tools/orte-checkpoint/orte-checkpoint.c b/orte/tools/orte-checkpoint/orte-checkpoint.c index b732f076348..4a70de47639 100644 --- a/orte/tools/orte-checkpoint/orte-checkpoint.c +++ b/orte/tools/orte-checkpoint/orte-checkpoint.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2007 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. @@ -389,7 +390,7 @@ static int parse_args(int argc, char *argv[]) { opal_cmd_line_create(&cmd_line, cmd_line_opts); mca_base_open(); mca_base_cmd_line_setup(&cmd_line); - ret = opal_cmd_line_parse(&cmd_line, true, argc, argv); + ret = opal_cmd_line_parse(&cmd_line, true, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { diff --git a/orte/tools/orte-clean/orte-clean.c b/orte/tools/orte-clean/orte-clean.c index ad83cf474cf..233c1c65d92 100644 --- a/orte/tools/orte-clean/orte-clean.c +++ b/orte/tools/orte-clean/orte-clean.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2008 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science @@ -197,7 +198,7 @@ static int parse_args(int argc, char *argv[]) { * Initialize list of available command line options. */ opal_cmd_line_create(&cmd_line, cmd_line_opts); - ret = opal_cmd_line_parse(&cmd_line, false, argc, argv); + ret = opal_cmd_line_parse(&cmd_line, false, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { diff --git a/orte/tools/orte-dvm/orte-dvm.c b/orte/tools/orte-dvm/orte-dvm.c index 479aed125b4..7bdc2e57bdd 100644 --- a/orte/tools/orte-dvm/orte-dvm.c +++ b/orte/tools/orte-dvm/orte-dvm.c @@ -1,5 +1,5 @@ -/* -*- C -*- - * +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2013-2016 Intel, Inc. All rights reserved. * $COPYRIGHT$ @@ -179,7 +179,7 @@ int main(int argc, char *argv[]) opal_cmd_line_create(&cmd_line, cmd_line_init); mca_base_cmd_line_setup(&cmd_line); - if (OPAL_SUCCESS != (rc = opal_cmd_line_parse(&cmd_line, true, + if (OPAL_SUCCESS != (rc = opal_cmd_line_parse(&cmd_line, true, false, argc, argv)) ) { if (OPAL_ERR_SILENT != rc) { fprintf(stderr, "%s: command line error (%s)\n", argv[0], diff --git a/orte/tools/orte-info/orte-info.c b/orte/tools/orte-info/orte-info.c index 5b2230fbb52..eb81da6f193 100644 --- a/orte/tools/orte-info/orte-info.c +++ b/orte/tools/orte-info/orte-info.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2010-2013 Los Alamos National Security, LLC. + * Copyright (c) 2010-2016 Los Alamos National Security, LLC. * All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science @@ -154,7 +155,7 @@ int main(int argc, char *argv[]) /* Do the parsing */ - ret = opal_cmd_line_parse(orte_info_cmd_line, false, argc, argv); + ret = opal_cmd_line_parse(orte_info_cmd_line, false, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { fprintf(stderr, "%s: command line error (%s)\n", argv[0], diff --git a/orte/tools/orte-migrate/orte-migrate.c b/orte/tools/orte-migrate/orte-migrate.c index 1a8bb11d0a4..dddf2d4fa15 100644 --- a/orte/tools/orte-migrate/orte-migrate.c +++ b/orte/tools/orte-migrate/orte-migrate.c @@ -1,9 +1,12 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2009-2010 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. + * Copyright (c) 2016 Los Alamos National Security, LLC. All rights + * reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -276,7 +279,7 @@ static int parse_args(int argc, char *argv[]) { opal_cmd_line_create(&cmd_line, cmd_line_opts); mca_base_open(); mca_base_cmd_line_setup(&cmd_line); - ret = opal_cmd_line_parse(&cmd_line, false, argc, argv); + ret = opal_cmd_line_parse(&cmd_line, false, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { diff --git a/orte/tools/orte-ps/orte-ps.c b/orte/tools/orte-ps/orte-ps.c index 9c008cd32a5..4f444ad0125 100644 --- a/orte/tools/orte-ps/orte-ps.c +++ b/orte/tools/orte-ps/orte-ps.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -11,7 +12,7 @@ * All rights reserved. * Copyright (c) 2006-2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2007 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. @@ -327,7 +328,7 @@ static int parse_args(int argc, char *argv[]) { mca_base_open(); mca_base_cmd_line_setup(&cmd_line); - ret = opal_cmd_line_parse(&cmd_line, false, argc, argv); + ret = opal_cmd_line_parse(&cmd_line, false, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { diff --git a/orte/tools/orte-restart/orte-restart.c b/orte/tools/orte-restart/orte-restart.c index 5b94a10093e..cd76c533fa9 100644 --- a/orte/tools/orte-restart/orte-restart.c +++ b/orte/tools/orte-restart/orte-restart.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -9,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2007 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. @@ -434,7 +435,7 @@ static int parse_args(int argc, char *argv[]) mca_base_open(); mca_base_cmd_line_setup(&cmd_line); - ret = opal_cmd_line_parse(&cmd_line, true, argc, argv); + ret = opal_cmd_line_parse(&cmd_line, true, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { diff --git a/orte/tools/orte-server/orte-server.c b/orte/tools/orte-server/orte-server.c index 46ef0b90465..a556cfc7bd0 100644 --- a/orte/tools/orte-server/orte-server.c +++ b/orte/tools/orte-server/orte-server.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2013 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. * $COPYRIGHT$ @@ -120,7 +121,7 @@ int main(int argc, char *argv[]) cmd_line = OBJ_NEW(opal_cmd_line_t); opal_cmd_line_create(cmd_line, orte_server_cmd_line_opts); mca_base_cmd_line_setup(cmd_line); - if (OPAL_SUCCESS != (ret = opal_cmd_line_parse(cmd_line, false, + if (OPAL_SUCCESS != (ret = opal_cmd_line_parse(cmd_line, false, false, argc, argv))) { if (OPAL_ERR_SILENT != ret) { fprintf(stderr, "%s: command line error (%s)\n", argv[0], diff --git a/orte/tools/orte-top/orte-top.c b/orte/tools/orte-top/orte-top.c index 0ca3d0691da..28d035f3ac8 100644 --- a/orte/tools/orte-top/orte-top.c +++ b/orte/tools/orte-top/orte-top.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ /* * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana * University Research and Technology @@ -10,7 +11,7 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved. - * Copyright (c) 2007-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved. * $COPYRIGHT$ @@ -234,7 +235,7 @@ main(int argc, char *argv[]) mca_base_open(); mca_base_cmd_line_setup(&cmd_line); - ret = opal_cmd_line_parse(&cmd_line, false, argc, argv); + ret = opal_cmd_line_parse(&cmd_line, false, false, argc, argv); if (OPAL_SUCCESS != ret) { if (OPAL_ERR_SILENT != ret) { fprintf(stderr, "%s: command line error (%s)\n", argv[0],