From: Pierre Veyre Date: Mon, 10 Mar 2014 10:46:33 +0000 (+0100) Subject: MSG_host_get_attached_storage_list and SD_workstation_get_attached_storage_list bug fix X-Git-Tag: v3_11~226 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5a5e8338f6d18da29438ec26f96970afb7579992 MSG_host_get_attached_storage_list and SD_workstation_get_attached_storage_list bug fix --- diff --git a/include/msg/msg.h b/include/msg/msg.h index e47696dab4..1c19a5cee5 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -155,7 +155,7 @@ XBT_PUBLIC(int) MSG_get_host_number(void); XBT_PUBLIC(void) MSG_host_get_params(msg_host_t ind_pm, ws_params_t params); XBT_PUBLIC(void) MSG_host_set_params(msg_host_t ind_pm, ws_params_t params); XBT_PUBLIC(xbt_dict_t) MSG_host_get_mounted_storage_list(msg_host_t host); -XBT_PUBLIC(xbt_dict_t) MSG_host_get_attached_storage_list(msg_host_t host); +XBT_PUBLIC(xbt_dynar_t) MSG_host_get_attached_storage_list(msg_host_t host); XBT_PUBLIC(xbt_dict_t) MSG_host_get_storage_content(msg_host_t host); /************************** Process handling *********************************/ XBT_PUBLIC(msg_process_t) MSG_process_create(const char *name, diff --git a/include/simdag/simdag.h b/include/simdag/simdag.h index 73c349c575..7bccbbb820 100644 --- a/include/simdag/simdag.h +++ b/include/simdag/simdag.h @@ -107,7 +107,7 @@ XBT_PUBLIC(SD_task_t) SD_workstation_get_current_task(SD_workstation_t workstation); XBT_PUBLIC(xbt_dict_t) SD_workstation_get_mounted_storage_list(SD_workstation_t workstation); -XBT_PUBLIC(xbt_dict_t) +XBT_PUBLIC(xbt_dynar_t) SD_workstation_get_attached_storage_list(SD_workstation_t workstation); /** @} */ diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index b4269840f9..c63d21bdd5 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -332,7 +332,7 @@ XBT_PUBLIC(void) simcall_host_execution_set_bound(smx_action_t execution, double XBT_PUBLIC(void) simcall_host_execution_set_affinity(smx_action_t execution, smx_host_t host, unsigned long mask); XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution); XBT_PUBLIC(xbt_dict_t) simcall_host_get_mounted_storage_list(smx_host_t host); -XBT_PUBLIC(xbt_dict_t) simcall_host_get_attached_storage_list(smx_host_t host); +XBT_PUBLIC(xbt_dynar_t) simcall_host_get_attached_storage_list(smx_host_t host); XBT_PUBLIC(void) simcall_host_get_params(smx_host_t vm, ws_params_t param); XBT_PUBLIC(void) simcall_host_set_params(smx_host_t vm, ws_params_t param); diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 083373d61e..1ec1f94fbb 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -653,7 +653,7 @@ XBT_PUBLIC(xbt_dict_t) surf_workstation_get_mounted_storage_list(surf_resource_t * @param workstation The surf workstation * @return Dictionary of storage */ -XBT_PUBLIC(xbt_dict_t) surf_workstation_get_attached_storage_list(surf_resource_t workstation); +XBT_PUBLIC(xbt_dynar_t) surf_workstation_get_attached_storage_list(surf_resource_t workstation); /** * @brief Unlink a file descriptor diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index 57fd96ca5c..65fc9b6c0e 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -413,7 +413,7 @@ xbt_dict_t MSG_host_get_mounted_storage_list(msg_host_t host) * \param host a host * \return a dict containing all storages attached to the host (storage name => msg_storage_t) */ -xbt_dict_t MSG_host_get_attached_storage_list(msg_host_t host) +xbt_dynar_t MSG_host_get_attached_storage_list(msg_host_t host) { xbt_assert((host != NULL), "Invalid parameters"); return (simcall_host_get_attached_storage_list(host)); diff --git a/src/simdag/sd_workstation.c b/src/simdag/sd_workstation.c index 87e30883f7..4c7aa384b4 100644 --- a/src/simdag/sd_workstation.c +++ b/src/simdag/sd_workstation.c @@ -486,7 +486,7 @@ xbt_dict_t SD_workstation_get_mounted_storage_list(SD_workstation_t workstation) * \param workstation a workstation * \return a dynar containing all mounted storages on the workstation */ -xbt_dict_t SD_workstation_get_attached_storage_list(SD_workstation_t workstation){ +xbt_dynar_t SD_workstation_get_attached_storage_list(SD_workstation_t workstation){ return surf_workstation_get_attached_storage_list(workstation); } diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index f0e3d62e8b..8328b476a7 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -31,7 +31,7 @@ host_execution_set_bound True (void) (execution, void*, smx_action_t) (bound, do host_execution_set_affinity True (void) (execution, void*, smx_action_t) (ws, void*, smx_host_t) (mask, unsigned long) host_execution_wait False (int) (execution, void*, smx_action_t) host_get_mounted_storage_list True (void*, xbt_dict_t) (host, void*, smx_host_t) -host_get_attached_storage_list True (void*, xbt_dict_t) (host, void*, smx_host_t) +host_get_attached_storage_list True (void*, xbt_dynar_t) (host, void*, smx_host_t) host_get_params True (void) (ind_vm, void*, smx_host_t) (params, void*, ws_params_t) host_set_params True (void) (ind_vm, void*, smx_host_t) (params, void*, ws_params_t) vm_create True (void*) (name, const char*) (ind_pm, void*, smx_host_t) diff --git a/src/simix/simcalls_generated_body.c b/src/simix/simcalls_generated_body.c index fb935f2ee5..8b98b8e693 100644 --- a/src/simix/simcalls_generated_body.c +++ b/src/simix/simcalls_generated_body.c @@ -412,7 +412,7 @@ } return self->simcall.result.dp; } - inline static xbt_dict_t simcall_BODY_host_get_attached_storage_list(smx_host_t host) { + inline static xbt_dynar_t simcall_BODY_host_get_attached_storage_list(smx_host_t host) { smx_process_t self = SIMIX_process_self(); self->simcall.call = SIMCALL_HOST_GET_ATTACHED_STORAGE_LIST; memset(&self->simcall.result, 0, sizeof(self->simcall.result)); diff --git a/src/simix/simcalls_generated_res_getter_setter.h b/src/simix/simcalls_generated_res_getter_setter.h index bff3f1f694..bcee19440f 100644 --- a/src/simix/simcalls_generated_res_getter_setter.h +++ b/src/simix/simcalls_generated_res_getter_setter.h @@ -129,8 +129,8 @@ static inline xbt_dict_t simcall_host_get_mounted_storage_list__get__result(smx_ static inline void simcall_host_get_mounted_storage_list__set__result(smx_simcall_t simcall, void* result){ simcall->result.dp = result; } -static inline xbt_dict_t simcall_host_get_attached_storage_list__get__result(smx_simcall_t simcall){ - return (xbt_dict_t) simcall->result.dp; +static inline xbt_dynar_t simcall_host_get_attached_storage_list__get__result(smx_simcall_t simcall){ + return (xbt_dynar_t) simcall->result.dp; } static inline void simcall_host_get_attached_storage_list__set__result(smx_simcall_t simcall, void* result){ simcall->result.dp = result; diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index 4ceb16851d..40f3c73e24 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -759,11 +759,11 @@ xbt_dict_t SIMIX_host_get_mounted_storage_list(smx_host_t host){ return surf_workstation_get_mounted_storage_list(host); } -xbt_dict_t SIMIX_pre_host_get_attached_storage_list(smx_simcall_t simcall, smx_host_t host){ +xbt_dynar_t SIMIX_pre_host_get_attached_storage_list(smx_simcall_t simcall, smx_host_t host){ return SIMIX_host_get_attached_storage_list(host); } -xbt_dict_t SIMIX_host_get_attached_storage_list(smx_host_t host){ +xbt_dynar_t SIMIX_host_get_attached_storage_list(smx_host_t host){ xbt_assert((host != NULL), "Invalid parameters (simix host is NULL)"); return surf_workstation_get_attached_storage_list(host); diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 0c8b50878b..2e17bcf1cc 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -67,7 +67,7 @@ void SIMIX_host_execution_set_bound(smx_action_t action, double bound); void SIMIX_host_execution_set_affinity(smx_action_t action, smx_host_t host, unsigned long mask); void SIMIX_pre_host_execution_wait(smx_simcall_t simcall, smx_action_t action); xbt_dict_t SIMIX_host_get_mounted_storage_list(smx_host_t host); -xbt_dict_t SIMIX_host_get_attached_storage_list(smx_host_t host); +xbt_dynar_t SIMIX_host_get_attached_storage_list(smx_host_t host); // pre prototypes smx_host_t SIMIX_pre_host_get_by_name(smx_simcall_t, const char*); const char* SIMIX_pre_host_self_get_name(smx_simcall_t); @@ -102,7 +102,7 @@ void SIMIX_host_execution_resume(smx_action_t action); void SIMIX_post_host_execute(smx_action_t action); xbt_dict_t SIMIX_pre_host_get_mounted_storage_list(smx_simcall_t, smx_host_t); -xbt_dict_t SIMIX_pre_host_get_attached_storage_list(smx_simcall_t, smx_host_t); +xbt_dynar_t SIMIX_pre_host_get_attached_storage_list(smx_simcall_t, smx_host_t); #ifdef HAVE_TRACING void SIMIX_pre_set_category(smx_simcall_t simcall, smx_action_t action, const char *category); diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index dd96fa5990..8feee85b1f 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1446,7 +1446,7 @@ xbt_dict_t simcall_host_get_mounted_storage_list(smx_host_t host) * \param host A SIMIX host * \return a dict containing all storages attached to the host */ -xbt_dict_t simcall_host_get_attached_storage_list(smx_host_t host) +xbt_dynar_t simcall_host_get_attached_storage_list(smx_host_t host) { return simcall_BODY_host_get_attached_storage_list(host); } diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 51c6f43d2f..7f8d40f35c 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -356,7 +356,7 @@ xbt_dict_t surf_workstation_get_mounted_storage_list(surf_resource_t workstation return get_casted_workstation(workstation)->getMountedStorageList(); } -xbt_dict_t surf_workstation_get_attached_storage_list(surf_resource_t workstation){ +xbt_dynar_t surf_workstation_get_attached_storage_list(surf_resource_t workstation){ return get_casted_workstation(workstation)->getAttachedStorageList(); } diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 6dd49af19b..0c117abd5d 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -370,6 +370,11 @@ static XBT_INLINE void surf_workstation_free(void *r) delete static_cast(r); } +static XBT_INLINE void surf_storage_free(void *r) +{ + delete static_cast(r); +} + void sg_version(int *ver_major,int *ver_minor,int *ver_patch) { *ver_major = SIMGRID_VERSION_MAJOR; @@ -397,6 +402,7 @@ void surf_init(int *argc, char **argv) SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_cpu_free); SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_workstation_free); SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_link_free); + SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_free); xbt_init(argc, argv); if (!model_list) diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index 9d93ab5296..71718e312e 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -184,24 +184,23 @@ xbt_dict_t Workstation::getMountedStorageList() return storage_list; } -xbt_dict_t Workstation::getAttachedStorageList() +xbt_dynar_t Workstation::getAttachedStorageList() { xbt_lib_cursor_t cursor; char *key; void **data; - xbt_dict_t res = xbt_dict_new_homogeneous(NULL); + xbt_dynar_t result = xbt_dynar_new(sizeof(void*), NULL); xbt_lib_foreach(storage_lib, cursor, key, data) { - if(routing_get_network_element_type(key) == SURF_STORAGE_LEVEL) { - xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor); - if ( (static_cast(surf_storage_resource_priv(surf_storage_resource_by_name((const char*)elm))))->p_attach == this->getName()) - xbt_dict_set(res,(const char*)elm,xbt_lib_get_level(elm,MSG_STORAGE_LEVEL),NULL); - } + if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) { + StoragePtr storage = static_cast(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL)); + if(!strcmp((const char*)storage->p_attach,this->getName())){ + xbt_dynar_push_as(result, void *,(void *)static_cast(storage)->getName()); + } + } } - return res; - + return result; } - ActionPtr Workstation::open(const char* mount, const char* path) { StoragePtr st = findStorageOnMountList(mount); XBT_DEBUG("OPEN on disk '%s'", st->getName()); diff --git a/src/surf/workstation_interface.hpp b/src/surf/workstation_interface.hpp index 9368025cff..8adf17460f 100644 --- a/src/surf/workstation_interface.hpp +++ b/src/surf/workstation_interface.hpp @@ -253,7 +253,7 @@ public: * * @return The xbt_dict_t of Storage */ - virtual xbt_dict_t getAttachedStorageList(); + virtual xbt_dynar_t getAttachedStorageList(); /** * @brief Open a file