Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'torus'
[simgrid.git] / src / simgrid / sg_config.c
index b812c87..c57b33c 100644 (file)
@@ -111,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)
 {
@@ -130,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)
 {
@@ -416,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;
@@ -452,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;
@@ -507,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);
@@ -841,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;
@@ -849,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");
@@ -893,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)