Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add disk usage and size parameters for storage.
[simgrid.git] / src / surf / surfxml_parse.c
index d23457a..91e0254 100644 (file)
@@ -86,6 +86,8 @@ xbt_dynar_t STag_surfxml_ASroute_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_ASroute_cb_list = NULL;
 xbt_dynar_t STag_surfxml_bypassRoute_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_bypassRoute_cb_list = NULL;
+xbt_dynar_t STag_surfxml_bypassASroute_cb_list = NULL;
+xbt_dynar_t ETag_surfxml_bypassASroute_cb_list = NULL;
 xbt_dynar_t STag_surfxml_include_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_include_cb_list = NULL;
 
@@ -142,6 +144,7 @@ void ETag_surfxml_storage_type(void)
   storage_type.id = A_surfxml_storage_type_id;
   storage_type.model = A_surfxml_storage_type_model;
   storage_type.properties = current_property_set;
+  storage_type.size = surf_parse_get_int(A_surfxml_storage_type_size);
   sg_platf_new_storage_type(&storage_type);
   current_property_set = NULL;
 }
@@ -181,7 +184,7 @@ static xbt_dynar_t surf_parsed_filename_stack = NULL;
 
 void STag_surfxml_include(void)
 {
-  XBT_INFO("STag_surfxml_include '%s'",A_surfxml_include_file);
+  XBT_DEBUG("STag_surfxml_include '%s'",A_surfxml_include_file);
   xbt_dynar_push(surf_parsed_filename_stack,&surf_parsed_filename); // save old file name
   surf_parsed_filename = xbt_strdup(A_surfxml_include_file);
 
@@ -216,22 +219,22 @@ void ETag_surfxml_include(void) {
 int ETag_surfxml_include_state(void)
 {
   fflush(NULL);
-  XBT_INFO("ETag_surfxml_include_state '%s'",A_surfxml_include_file);
+  XBT_DEBUG("ETag_surfxml_include_state '%s'",A_surfxml_include_file);
 
-  if(!xbt_dynar_is_empty(surf_input_buffer_stack)) // nope, that's a true premature EOF. Let the parser die verbosely.
-         return 1;
+  if(xbt_dynar_is_empty(surf_input_buffer_stack)) // nope, that's a true premature EOF. Let the parser die verbosely.
+         return 0;
 
   // Yeah, we were in an <include> Restore state and proceed.
   fclose(surf_file_to_parse);
   xbt_dynar_pop(surf_file_to_parse_stack, &surf_file_to_parse);
   surf_parse_pop_buffer_state();
-  xbt_dynar_pop(surf_input_buffer_stack,surf_input_buffer);
+  xbt_dynar_pop(surf_input_buffer_stack,&surf_input_buffer);
 
   // Restore the filename for error messages
   free(surf_parsed_filename);
   xbt_dynar_pop(surf_parsed_filename_stack,&surf_parsed_filename);
 
-  return 0;
+  return 1;
 }
 
 
@@ -271,6 +274,10 @@ void surf_parse_init_callbacks(void)
              xbt_dynar_new(sizeof(void_f_void_t), NULL);
          ETag_surfxml_bypassRoute_cb_list =
              xbt_dynar_new(sizeof(void_f_void_t), NULL);
+      STag_surfxml_bypassASroute_cb_list =
+          xbt_dynar_new(sizeof(void_f_void_t), NULL);
+      ETag_surfxml_bypassASroute_cb_list =
+          xbt_dynar_new(sizeof(void_f_void_t), NULL);
          STag_surfxml_peer_cb_list =
              xbt_dynar_new(sizeof(void_f_void_t), NULL);
          ETag_surfxml_peer_cb_list =
@@ -320,6 +327,8 @@ void surf_parse_free_callbacks(void)
   xbt_dynar_free(&ETag_surfxml_ASroute_cb_list);
   xbt_dynar_free(&STag_surfxml_bypassRoute_cb_list);
   xbt_dynar_free(&ETag_surfxml_bypassRoute_cb_list);
+  xbt_dynar_free(&STag_surfxml_bypassASroute_cb_list);
+  xbt_dynar_free(&ETag_surfxml_bypassASroute_cb_list);
   xbt_dynar_free(&STag_surfxml_peer_cb_list);
   xbt_dynar_free(&ETag_surfxml_peer_cb_list);
   xbt_dynar_free(&STag_surfxml_include_cb_list);
@@ -381,8 +390,8 @@ void ETag_surfxml_host(void)    {
   host.power_peak = get_cpu_power(A_surfxml_host_power);
   host.power_scale = surf_parse_get_double( A_surfxml_host_availability);
   host.core_amount = surf_parse_get_int(A_surfxml_host_core);
-  host.power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
-  host.state_trace = tmgr_trace_new(A_surfxml_host_state_file);
+  host.power_trace = tmgr_trace_new_from_file(A_surfxml_host_availability_file);
+  host.state_trace = tmgr_trace_new_from_file(A_surfxml_host_state_file);
   xbt_assert((A_surfxml_host_state == A_surfxml_host_state_ON) ||
         (A_surfxml_host_state == A_surfxml_host_state_OFF), "Invalid state");
   if (A_surfxml_host_state == A_surfxml_host_state_ON)
@@ -467,8 +476,8 @@ void STag_surfxml_peer(void){
        peer.bw_out = surf_parse_get_double(A_surfxml_peer_bw_out);
        peer.lat = surf_parse_get_double(A_surfxml_peer_lat);
        peer.coord = A_surfxml_peer_coordinates;
-       peer.availability_trace = tmgr_trace_new(A_surfxml_peer_availability_file);
-       peer.state_trace = tmgr_trace_new(A_surfxml_peer_state_file);
+       peer.availability_trace = tmgr_trace_new_from_file(A_surfxml_peer_availability_file);
+       peer.state_trace = tmgr_trace_new_from_file(A_surfxml_peer_state_file);
 
        surfxml_call_cb_functions(STag_surfxml_peer_cb_list);
        sg_platf_new_peer(&peer);
@@ -487,9 +496,9 @@ void ETag_surfxml_link(void){
 
   link.id = A_surfxml_link_id;
   link.bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth);
-  link.bandwidth_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file);
+  link.bandwidth_trace = tmgr_trace_new_from_file(A_surfxml_link_bandwidth_file);
   link.latency = surf_parse_get_double(A_surfxml_link_latency);
-  link.latency_trace = tmgr_trace_new(A_surfxml_link_latency_file);
+  link.latency_trace = tmgr_trace_new_from_file(A_surfxml_link_latency_file);
 
   switch (A_surfxml_link_state) {
   case A_surfxml_link_state_ON:
@@ -502,7 +511,7 @@ void ETag_surfxml_link(void){
     surf_parse_error("invalid state for link %s", link.id);
     break;
   }
-  link.state_trace = tmgr_trace_new(A_surfxml_link_state_file);
+  link.state_trace = tmgr_trace_new_from_file(A_surfxml_link_state_file);
 
   switch (A_surfxml_link_sharing_policy) {
   case A_surfxml_link_sharing_policy_SHARED:
@@ -557,6 +566,9 @@ void STag_surfxml_ASroute(void){
 void STag_surfxml_bypassRoute(void){
        surfxml_call_cb_functions(STag_surfxml_bypassRoute_cb_list);
 }
+void STag_surfxml_bypassASroute(void){
+  surfxml_call_cb_functions(STag_surfxml_bypassASroute_cb_list);
+}
 void STag_surfxml_config(void){
   XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
   xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
@@ -594,6 +606,7 @@ parse_method(E, trace_connect)
 parse_method(E, random)
 parse_method(E, ASroute)
 parse_method(E, bypassRoute)
+parse_method(E, bypassASroute)
 
 /* Open and Close parse file */
 
@@ -615,8 +628,8 @@ void surf_parse_open(const char *file)
   if (!surf_file_to_parse_stack)
     surf_file_to_parse_stack = xbt_dynar_new(sizeof(FILE *), NULL);
 
-  if (!surf_file_to_parse_stack)
-    surf_parsed_filename_stack = xbt_dynar_new(sizeof(FILE *), xbt_free_f);
+  if (!surf_parsed_filename_stack)
+    surf_parsed_filename_stack = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
   surf_parsed_filename = xbt_strdup(file);
 
   surf_file_to_parse = surf_fopen(file, "r");