X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3e4a847beed6640a47ddf93b4d31e33140b42632..13e0c316176dfe56c04b66d96b65a174e76d0549:/src/simgrid/sg_config.c diff --git a/src/simgrid/sg_config.c b/src/simgrid/sg_config.c index 0f88330755..c57b33cf0e 100644 --- a/src/simgrid/sg_config.c +++ b/src/simgrid/sg_config.c @@ -55,6 +55,9 @@ static void sg_config_cmd_line(int *argc, char **argv) xbt_cfg_set_parse(_sg_cfg_set, opt); XBT_DEBUG("Did apply '%s' as config setting", opt); + } else if (!strcmp(argv[i], "--version")) { + printf("%s\n", SIMGRID_VERSION_STRING); + shall_exit = 1; } else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) { printf ("Description of the configuration accepted by this simulator:\n"); @@ -71,6 +74,8 @@ static void sg_config_cmd_line(int *argc, char **argv) #endif "\n" "You can also use --help-logs and --help-log-categories to see the details of logging output.\n" +"\n" +"You can also use --version to get SimGrid version information.\n" "\n" ); shall_exit = 1; @@ -106,6 +111,27 @@ static void sg_config_cmd_line(int *argc, char **argv) sg_cfg_exit_early(); } +/* callback of the plugin variable */ +static void _sg_cfg_cb__plugin(const char *name, int pos) +{ + char *val; + + XBT_VERB("PLUGIN"); + xbt_assert(_sg_cfg_init_status < 2, + "Cannot load a plugin after the initialization"); + + val = xbt_cfg_get_string(_sg_cfg_set, name); + + if (!strcmp(val, "help")) { + model_help("plugin", surf_plugin_description); + sg_cfg_exit_early(); + } + + /* New Module missing */ + int plugin_id = find_model_description(surf_plugin_description, val); + surf_plugin_description[plugin_id].model_init_preparse(); +} + /* callback of the workstation/model variable */ static void _sg_cfg_cb__workstation_model(const char *name, int pos) { @@ -125,6 +151,25 @@ static void _sg_cfg_cb__workstation_model(const char *name, int pos) find_model_description(surf_workstation_model_description, val); } +/* callback of the vm_workstation/model variable */ +static void _sg_cfg_cb__vm_workstation_model(const char *name, int pos) +{ + char *val; + + xbt_assert(_sg_cfg_init_status < 2, + "Cannot change the model after the initialization"); + + val = xbt_cfg_get_string(_sg_cfg_set, name); + + if (!strcmp(val, "help")) { + model_help("vm_workstation", surf_vm_workstation_model_description); + sg_cfg_exit_early(); + } + + /* Make sure that the model exists */ + find_model_description(surf_vm_workstation_model_description, val); +} + /* callback of the cpu/model variable */ static void _sg_cfg_cb__cpu_model(const char *name, int pos) { @@ -411,6 +456,21 @@ void sg_config_init(int *argc, char **argv) /* Create the configuration support */ if (_sg_cfg_init_status == 0) { /* Only create stuff if not already inited */ + + /* Plugins configuration */ + + sprintf(description, + "The plugins. Possible values: "); + p = description; + while (*(++p) != '\0'); + for (i = 0; surf_plugin_description[i].name; i++) + p += sprintf(p, "%s%s", (i == 0 ? "" : ", "), + surf_plugin_description[i].name); + sprintf(p, + ".\n (use 'help' as a value to see the long description of each plugin)"); + xbt_cfg_register(&_sg_cfg_set, "plugin", description, + xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__plugin, NULL); + sprintf(description, "The model to use for the CPU. Possible values: "); p = description; @@ -447,22 +507,6 @@ void sg_config_init(int *argc, char **argv) xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__storage_mode, NULL); xbt_cfg_setdefault_string(_sg_cfg_set, "storage/model", "default"); - /* ********************************************************************* */ - /* TUTORIAL: New model */ - sprintf(description, - "The model to use for the New model. Possible values: "); - p = description; - while (*(++p) != '\0'); - for (i = 0; surf_new_model_description[i].name; i++) - p += sprintf(p, "%s%s", (i == 0 ? "" : ", "), - surf_new_model_description[i].name); - sprintf(p, - ".\n (use 'help' as a value to see the long description of each model)"); - xbt_cfg_register(&_sg_cfg_set, "new_model/model", description, - xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__storage_mode, NULL); - xbt_cfg_setdefault_string(_sg_cfg_set, "new_model/model", "default"); - /* ********************************************************************* */ - sprintf(description, "The model to use for the network. Possible values: "); p = description; @@ -502,6 +546,10 @@ void sg_config_init(int *argc, char **argv) xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__workstation_model, NULL); xbt_cfg_setdefault_string(_sg_cfg_set, "workstation/model", "default"); + xbt_cfg_register(&_sg_cfg_set, "vm_workstation/model", description, + xbt_cfgelm_string, 1, 1, &_sg_cfg_cb__vm_workstation_model, NULL); + xbt_cfg_setdefault_string(_sg_cfg_set, "vm_workstation/model", "default"); + xbt_cfg_register(&_sg_cfg_set, "network/TCP_gamma", "Size of the biggest TCP window (cat /proc/sys/net/ipv4/tcp_[rw]mem for recv/send window; Use the last given value, which is the max window size)", xbt_cfgelm_double, 1, 1, _sg_cfg_cb__tcp_gamma, NULL); @@ -836,7 +884,9 @@ void sg_config_finalize(void) void surf_config_models_setup() { const char *workstation_model_name; + const char *vm_workstation_model_name; int workstation_id = -1; + int vm_workstation_id = -1; char *network_model_name = NULL; char *cpu_model_name = NULL; int storage_id = -1; @@ -844,6 +894,8 @@ void surf_config_models_setup() workstation_model_name = xbt_cfg_get_string(_sg_cfg_set, "workstation/model"); + vm_workstation_model_name = + xbt_cfg_get_string(_sg_cfg_set, "vm_workstation/model"); network_model_name = xbt_cfg_get_string(_sg_cfg_set, "network/model"); cpu_model_name = xbt_cfg_get_string(_sg_cfg_set, "cpu/model"); storage_model_name = xbt_cfg_get_string(_sg_cfg_set, "storage/model"); @@ -888,19 +940,15 @@ void surf_config_models_setup() XBT_DEBUG("Call workstation_model_init"); surf_workstation_model_description[workstation_id].model_init_preparse(); + XBT_DEBUG("Call vm_workstation_model_init"); + vm_workstation_id = find_model_description(surf_vm_workstation_model_description, + vm_workstation_model_name); + surf_vm_workstation_model_description[vm_workstation_id].model_init_preparse(); + XBT_DEBUG("Call storage_model_init"); storage_id = find_model_description(surf_storage_model_description, storage_model_name); surf_storage_model_description[storage_id].model_init_preparse(); - /* ********************************************************************* */ - /* TUTORIAL: New model */ - int new_model_id = -1; - char *new_model_name = NULL; - new_model_name = xbt_cfg_get_string(_sg_cfg_set, "new_model/model"); - XBT_DEBUG("Call new model_init"); - new_model_id = find_model_description(surf_new_model_description, new_model_name); - surf_new_model_description[new_model_id].model_init_preparse(); - /* ********************************************************************* */ } int sg_cfg_get_int(const char* name)