Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Still fixing bugs - Adrien
authoralebre <adrien.lebre@inria.fr>
Thu, 31 Jan 2013 22:41:39 +0000 (23:41 +0100)
committeralebre <adrien.lebre@inria.fr>
Thu, 31 Jan 2013 22:41:39 +0000 (23:41 +0100)
include/simgrid/simix.h
src/msg/instr_msg_vm.c
src/msg/msg_vm.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/simix/smx_vm.c

index 46763d4..679b3ab 100644 (file)
@@ -328,6 +328,13 @@ XBT_PUBLIC(e_smx_state_t) simcall_host_execution_get_state(smx_action_t executio
 XBT_PUBLIC(void) simcall_host_execution_set_priority(smx_action_t execution, double priority);
 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
 
+/******************************* VM simcalls ********************************/
+// Create the vm_workstation at the SURF level
+XBT_PUBLIC(void*) simcall_vm_ws_create(const char *name, smx_host_t host);
+XBT_PUBLIC(void*) simcall_get_vm_state(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_start(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_suspend(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_destroy(smx_host_t vm);
 
 /**************************** Process simcalls ********************************/
 /* Constructor and Destructor */
index 232c440..770f4cf 100644 (file)
@@ -66,6 +66,20 @@ void TRACE_msg_vm_create (const char *vm_name, msg_host_t host)
   }
 }
 
+void TRACE_msg_vm_start (msg_vm_t vm)
+{
+  if (TRACE_msg_vm_is_enabled()){
+    int len = INSTR_DEFAULT_STR_SIZE;
+    char str[INSTR_DEFAULT_STR_SIZE];
+
+    container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len));
+    type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type);
+    val_t value = PJ_value_get ("start", type);
+    new_pajePushState (MSG_get_clock(), vm_container, type, value);
+  }
+
+}
+
 void TRACE_msg_vm_kill(msg_vm_t vm) {
   if (TRACE_msg_vm_is_enabled()) {
     int len = INSTR_DEFAULT_STR_SIZE;
index c6ce9b0..be8e935 100644 (file)
@@ -3,6 +3,12 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+
+// TODO
+// 1./ check how and where a new VM is added to the list of the hosts
+// 2./ MSG_TRACE can be revisited in order to use  the host
+
+
 #include "msg_private.h"
 #include "xbt/sysdep.h"
 #include "xbt/log.h"
@@ -78,20 +84,6 @@ const char *MSG_vm_get_name(msg_vm_t vm) {
   return MSG_host_get_name(vm);
 }
 
-/** @brief Returns a newly constructed dynar containing all existing VMs in the system.
- *  @ingroup msg_VMs
- *
- * Don't forget to free the dynar after use.
- */
-xbt_dynar_t MSG_vms_as_dynar(void) {
-  xbt_dynar_t res = xbt_dynar_new(sizeof(msg_vm_t),NULL);
-  msg_vm_t vm;
-  xbt_swag_foreach(vm,msg_global->vms) {
-    xbt_dynar_push(res,&vm);
-  }
-  return res;
-}
-
 /* **** ******** MSG vm actions ********* **** */
 
 /** @brief Create a new VM (the VM is just attached to the location but it is not started yet).
@@ -100,15 +92,15 @@ xbt_dynar_t MSG_vms_as_dynar(void) {
  * Please note that a VM is a specific host. Hence, you should give a different name
  * for each VM/PM.
  */
-msg_vm_t MSG_vm_create(msg_host_t location, const char *name,
+msg_vm_t MSG_vm_create(msg_host_t ind_host, const char *name,
                                             int core_nb, int mem_cap, int net_cap){
 
   // Note new and vm_workstation refer to the same area (due to the lib/dict appraoch)
   msg_vm_t new = NULL;
-  void *vm_workstation =  NULL;
+  void *ind_vm_workstation =  NULL;
   // Ask simix to create the surf vm resource
-  vm_workstation = simcall_vm_create(name,location);
-  new = (msg_vm_t) __MSG_host_create(vm_workstation);
+  ind_vm_workstation = simcall_vm_ws_create(name,ind_host);
+  new = (msg_vm_t) __MSG_host_create(ind_vm_workstation);
 
   MSG_vm_set_property_value(new, "CORE_NB", bprintf("%d", core_nb), free);
   MSG_vm_set_property_value(new, "MEM_CAP", bprintf("%d", core_nb), free);
@@ -118,7 +110,7 @@ msg_vm_t MSG_vm_create(msg_host_t location, const char *name,
   // TODO check whether the vm (i.e the virtual host) has been correctly added into the list of all hosts.
 
   #ifdef HAVE_TRACING
-  TRACE_msg_vm_create(name, location);
+  TRACE_msg_vm_create(name, ind_host);
   #endif
 
   return new;
@@ -149,13 +141,13 @@ int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) {
  *  @ingroup msg_VMs
  */
 int MSG_vm_is_suspended(msg_vm_t vm) {
-       return __MSG_vm_is_state(msg_vm_state_suspended);
+       return __MSG_vm_is_state(vm, msg_vm_state_suspended);
 }
 /** @brief Returns whether the given VM is currently running
  *  @ingroup msg_VMs
  */
 int MSG_vm_is_running(msg_vm_t vm) {
-  return __MSG_vm_is_state(msg_vm_state_running);
+  return __MSG_vm_is_state(vm, msg_vm_state_running);
 }
 
 // TODO Implement the functions for the different state
index 39296de..768b20d 100644 (file)
@@ -274,11 +274,11 @@ ACTION(SIMCALL_HOST_EXECUTION_GET_REMAINS, host_execution_get_remains, WITH_ANSW
 ACTION(SIMCALL_HOST_EXECUTION_GET_STATE, host_execution_get_state, WITH_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_SET_PRIORITY, host_execution_set_priority, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t), TDOUBLE(priority)) sep \
 ACTION(SIMCALL_HOST_EXECUTION_WAIT, host_execution_wait, WITHOUT_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
-ACTION(SIMCALL_VM_CREATE, vm_create, WITH_ANSWER, TPTR(result), TSTRING(name), TSPEC(phys_host, smx_host_t)) sep \
-ACTION(SIMCALL_VM_START, vm_start, WITHOUT_ANSWER, TVOID(result), TSPEC(phys_host, smx_host_t)) sep \
-ACTION(SIMCALL_VM_SET_STATE, vm_set_state, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t), TINT(state)) sep \
-ACTION(SIMCALL_VM_GET_STATE, vm_get_state, WITH_ANSWER, TINT(result), TSPEC(vm, smx_host_t)) sep \
-ACTION(SIMCALL_VM_DESTROY, vm_destroy, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t)) sep \
+ACTION(SIMCALL_VM_WS_CREATE, vm_ws_create, WITH_ANSWER, TPTR(result), TSTRING(name), TSPEC(phys_host, smx_host_t)) sep \
+ACTION(SIMCALL_VM_START, vm_start, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_phys_host, smx_host_t)) sep \
+ACTION(SIMCALL_VM_SET_STATE, vm_set_state, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t), TINT(state)) sep \
+ACTION(SIMCALL_VM_GET_STATE, vm_get_state, WITH_ANSWER, TINT(result), TSPEC(ind_vm, smx_host_t)) sep \
+ACTION(SIMCALL_VM_DESTROY, vm_destroy, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t)) sep \
 ACTION(SIMCALL_PROCESS_CREATE, process_create, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t*), TSTRING(name), TSPEC(code, xbt_main_func_t), TPTR(data), TSTRING(hostname), TDOUBLE(kill_time), TINT(argc), TSPEC(argv, char**), TSPEC(properties, xbt_dict_t), TINT(auto_restart)) sep \
 ACTION(SIMCALL_PROCESS_KILL, process_kill, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
 ACTION(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result)) sep \
index 5c1394f..c345360 100644 (file)
@@ -282,20 +282,17 @@ e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
  * \param host A host
  * \return The properties of this host
  */
-void* simcall_vm_create(const char *name, smx_host_t phys_host){
-{
-  return simcall_BODY_vm_create(name, phys_host);
+void* simcall_vm_ws_create(const char *name, smx_host_t phys_host){
+  return simcall_BODY_vm_ws_create(name, phys_host);
 }
 
-
-void simcall_vm_start(smx_host_t vm){
+void simcall_vm_start(smx_host_t vm) {
 
        simcall_BODY_set_vm_state(vm, msg_vm_state_running);
 }
 
-void simcall_vm_destroy(smx_host_t vm)
-{
-  return simcall_BODY_vm_destroy(vm);
+void simcall_vm_destroy(smx_host_t vm) {
+  simcall_BODY_vm_destroy(vm);
 }
 
 /**
index 37c25aa..1577cb6 100644 (file)
 #include "xbt/dict.h"
 #include "mc/mc.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix,
-                                "Logging specific to SIMIX (vms)");
+//If you need to log some stuffs, just uncomment these two lines and uses XBT_DEBUG for instance
+//XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix,
+//                                "Logging specific to SIMIX (vms)");
+
 /* **** create a VM **** */
 
 /**
@@ -19,7 +21,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix,
  * \param name name of the host to create
  * \param data some user data (may be NULL)
  */
-smx_host_t SIMIX_vm_create(const char *name, smx_host_t phys_host)
+smx_host_t SIMIX_vm_create(const char *name, smx_host_t ind_phys_host)
 {
 
   smx_host_priv_t smx_host = xbt_new0(s_smx_host_priv_t, 1);
@@ -37,14 +39,14 @@ smx_host_t SIMIX_vm_create(const char *name, smx_host_t phys_host)
 
   /* Create surf associated resource */
   // TODO change phys_host into the right workstation surf model
-  surf_vm_workstation_model->extension.vm_workstation.create(name, phys_host);
+  surf_vm_workstation_model->extension.vm_workstation.create(name, ind_phys_host);
 
   return xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 
-smx_host_t SIMIX_pre_vm_create(smx_simcall_t simcall, const char *name, smx_host_t phys_host){
-   return SIMIX_vm_create(name, phys_host);
+smx_host_t SIMIX_pre_vm_create(smx_simcall_t simcall, const char *name, smx_host_t ind_phys_host){
+   return SIMIX_vm_create(name, ind_phys_host);
 }
 
 
@@ -53,32 +55,32 @@ int __can_be_started(smx_host_t vm){
        // TODO add checking code related to overcommitment or not.
        return 1;
 }
-void SIMIX_vm_start(smx_host_t vm){
+void SIMIX_vm_start(smx_host_t ind_vm){
 
   //TODO only start the VM if you can
-  if (can_be_started(vm))
-         SIMIX_set_vm_state(vm, msg_vm_state_running);
+  if (can_be_started(ind_vm))
+         SIMIX_set_vm_state(ind_vm, msg_vm_state_running);
   else
-         THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(vm));
+         THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm));
 }
 
-void SIMIX_pre_vm_start(smx_simcall_t simcall, smx_host_t vm){
+void SIMIX_pre_vm_start(smx_simcall_t simcall, smx_host_t ind_vm){
    SIMIX_vm_start(vm);
 }
 
 /* ***** set/get state of a VM ***** */
-void SIMIX_set_vm_state(smx_host_t vm, int state){
-       surf_vm_workstation_model->extension.vm_workstation.set_state(vm, state);
+void SIMIX_set_vm_state(smx_host_t ind_vm, int state){
+       surf_vm_workstation_model->extension.vm_workstation.set_state(ind_vm, state);
 }
-void SIMIX_prev_set_vm_state(smx_host_t vm, int state){
-       SIMIX_set_vm_state(vm, state);
+void SIMIX_prev_set_vm_state(smx_host_t ind_vm, int state){
+       SIMIX_set_vm_state(ind_vm, state);
 }
 
-int SIMIX_get_vm_state(smx_host_t vm){
- return surf_vm_workstation_model->extension.vm_workstation.get_state(vm);
+int SIMIX_get_vm_state(smx_host_t ind_vm){
+ return surf_vm_workstation_model->extension.vm_workstation.get_state(ind_vm);
 }
-int SIMIX_pre_vm_state(smx_host_t vm){
-       return SIMIX_get_vm_state(vm);
+int SIMIX_pre_vm_state(smx_host_t ind_vm){
+       return SIMIX_get_vm_state(ind_vm);
 }
 
 /**
@@ -86,12 +88,12 @@ int SIMIX_pre_vm_state(smx_host_t vm){
  *
  * \param host the vm host to destroy (a smx_host_t)
  */
-void SIMIX_vm_destroy(smx_host_t host)
+void SIMIX_vm_destroy(smx_host_t ind_vm)
 {
   /* this code basically performs a similar thing like SIMIX_host_destroy() */
 
   xbt_assert((host != NULL), "Invalid parameters");
-  char *hostname = host->key;
+  char *hostname = SIMIX_host_get_name(ind_vm);
 
   smx_host_priv_t host_priv = SIMIX_host_priv(host);
 
@@ -99,9 +101,9 @@ void SIMIX_vm_destroy(smx_host_t host)
   xbt_lib_unset(host_lib, hostname, SIMIX_HOST_LEVEL);
 
   /* jump to vm_ws_destroy(). The surf level resource will be freed. */
-  surf_vm_workstation_model->extension.vm_workstation.destroy(host);
+  surf_vm_workstation_model->extension.vm_workstation.destroy(ind_vm);
 }
 
-void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t vm){
-   SIMIX_vm_start(vm);
+void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t ind_vm){
+   SIMIX_vm_destroy(ind_vm);
 }