Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix conflict - Adrien
authoralebre <adrien.lebre@inria.fr>
Thu, 31 Jan 2013 22:45:43 +0000 (23:45 +0100)
committeralebre <adrien.lebre@inria.fr>
Thu, 31 Jan 2013 22:45:43 +0000 (23:45 +0100)
include/msg/datatypes.h
src/include/surf/surf.h
src/msg/msg_vm.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/simix/smx_vm.c
src/xbt/lib.c

index 755d900..e5b3ea1 100644 (file)
@@ -93,10 +93,10 @@ typedef struct msg_hypervisor {
        xbt_dynar_t vms;   // vms on this hypervisor
        msg_host_t host;  // physical host of this hypervisor
 
-  /* The hypervisor object does not have parameters like the number of CPU
- Ê * cores and the size of memory. These parameters come from those of the
- Ê * physical host.
- Ê **/
+/* The hypervisor object does not have parameters like the number of CPU
+* cores and the size of memory. These parameters come from those of the
+* physical host.
+**/
        int overcommit;
 
 } s_msg_hypervisor_t;
index 2c28873..441070f 100644 (file)
@@ -608,6 +608,16 @@ XBT_PUBLIC_DATA(s_surf_model_description_t) surf_storage_model_description[];
  */
 XBT_PUBLIC_DATA(surf_model_t) surf_workstation_model;
 
+/** \ingroup SURF_models
+ *  \brief The vm_workstation model
+ *
+ *  Note that when you create an API on top of SURF,
+ *  the vm_workstation model should be the only one you use
+ *  because depending on the platform model, the network model and the CPU model
+ *  may not exist.
+ */
+XBT_PUBLIC_DATA(surf_model_t) surf_vm_workstation_model;
+
 /** \ingroup SURF_models
  *  \brief Initializes the platform with a compound workstation model
  *
index be8e935..71a614d 100644 (file)
@@ -157,11 +157,9 @@ void MSG_vm_shutdown(msg_vm_t vm)
   /* msg_vm_t equals to msg_host_t */
   simcall_vm_shutdown(vm);
 
-  /* taka: not yet confirmed */
-  #ifdef HAVE_TRACING
-  TRACE_msg_vm_kill(vm);
-  #endif
-
+  // #ifdef HAVE_TRACING
+  // TRACE_msg_vm_(vm);
+  // #endif
 }
 
 
@@ -223,25 +221,31 @@ void MSG_vm_shutdown(msg_vm_t vm)
 //  vm->location = destination;
 //}
 //
-///** @brief Immediately suspend the execution of all processes within the given VM.
-// *  @ingroup msg_VMs
-// *
-// * No suspension cost occurs. If you want to simulate this too, you want to
-// * use a \ref MSG_file_write() before or after, depending on the exact semantic
-// * of VM suspend to you.
-// */
-//void MSG_vm_suspend(msg_vm_t vm) {
-//  unsigned int cpt;
-//  msg_process_t process;
-//  xbt_dynar_foreach(vm->processes,cpt,process) {
-//    XBT_DEBUG("suspend process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
-//    MSG_process_suspend(process);
-//  }
-//
-//  #ifdef HAVE_TRACING
-//  TRACE_msg_vm_suspend(vm);
-//  #endif
-//}
+
+/** @brief Immediately suspend the execution of all processes within the given VM.
+ *  @ingroup msg_VMs
+ *
+ * No suspension cost occurs. If you want to simulate this too, you want to
+ * use a \ref MSG_file_write() before or after, depending on the exact semantic
+ * of VM suspend to you.
+ */
+void MSG_vm_suspend(msg_vm_t vm)
+{
+  simcall_vm_suspend(vm);
+
+  #ifdef HAVE_TRACING
+  TRACE_msg_vm_suspend(vm);
+  #endif
+#if 0
+  unsigned int cpt;
+  msg_process_t process;
+  xbt_dynar_foreach(vm->processes,cpt,process) {
+    XBT_DEBUG("suspend process %s of host %s",MSG_process_get_name(process),MSG_host_get_name(MSG_process_get_host(process)));
+    MSG_process_suspend(process);
+  }
+#endif
+}
+
 //
 //
 ///** @brief Immediately resumes the execution of all processes within the given VM.
@@ -289,28 +293,32 @@ void MSG_vm_shutdown(msg_vm_t vm)
 //  xbt_dynar_free(&new_processes);
 //}
 //
-///** @brief Destroy a msg_vm_t.
-// *  @ingroup msg_VMs
-// */
-//void MSG_vm_destroy(msg_vm_t vm)
-//{
-//  simcall_vm_destroy(vm);
-//
-//#if 0
-//  unsigned int cpt;
-//  msg_process_t process;
-//  xbt_dynar_foreach(vm->processes,cpt,process) {
-//    //FIXME: Slow ?
-//    simdata_process_t simdata = simcall_process_get_data(process);
-//    simdata->vm = NULL;
-//  }
-//
-//  #ifdef HAVE_TRACING
-//  TRACE_msg_vm_end(vm);
-//  #endif
-//
-//
-//  xbt_dynar_free(&vm->processes);
-//  xbt_free(vm);
-//#endif
-//}
+
+/** @brief Destroy a VM. Destroy the VM object from the simulation.
+ *  @ingroup msg_VMs
+ */
+void MSG_vm_destroy(msg_vm_t vm)
+{
+  /* First, terminate all processes on the VM */
+  simcall_vm_shutdown(vm);
+
+  /* Then, destroy the VM object */
+  simcall_vm_destroy(vm);
+
+  #ifdef HAVE_TRACING
+  TRACE_msg_vm_end(vm);
+  #endif
+
+#if 0
+  unsigned int cpt;
+  msg_process_t process;
+  xbt_dynar_foreach(vm->processes,cpt,process) {
+    //FIXME: Slow ?
+    simdata_process_t simdata = simcall_process_get_data(process);
+    simdata->vm = NULL;
+  }
+
+  xbt_dynar_free(&vm->processes);
+  xbt_free(vm);
+#endif
+}
index 768b20d..2cbffe9 100644 (file)
@@ -279,6 +279,8 @@ ACTION(SIMCALL_VM_START, vm_start, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_phys
 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_VM_SUSPEND, vm_suspend, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t)) sep \
+ACTION(SIMCALL_VM_SHUTDOWN, vm_shutdown, WITHOUT_ANSWER, TVOID(result), TSPEC(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 c345360..a7aa1e5 100644 (file)
@@ -287,11 +287,28 @@ void* simcall_vm_ws_create(const char *name, smx_host_t phys_host){
 }
 
 void simcall_vm_start(smx_host_t vm) {
+{
+  simcall_BODY_set_vm_state(vm, msg_vm_state_running);
+}
+
+void simcall_vm_suspend(smx_host_t vm)
+{
+  /* will jump to SIMIX_pre_vm_suspend */
+  simcall_BODY_vm_suspend(vm);
+}
 
-       simcall_BODY_set_vm_state(vm, msg_vm_state_running);
+void simcall_vm_shutdown(smx_host_t vm)
+{
+  /* will jump to SIMIX_pre_vm_shutdown */
+  simcall_BODY_vm_shutdown(vm);
 }
 
-void simcall_vm_destroy(smx_host_t vm) {
+void simcall_vm_destroy(smx_host_t vm)
+{
+  /*
+   * simcall_BODY_ is defined in src/simix/smx_smurf_private.h.
+   * This function will jump to SIMIX_pre_vm_destroy.
+   **/
   simcall_BODY_vm_destroy(vm);
 }
 
index 1577cb6..e00aabc 100644 (file)
@@ -83,6 +83,60 @@ int SIMIX_pre_vm_state(smx_host_t ind_vm){
        return SIMIX_get_vm_state(ind_vm);
 }
 
+/**
+ * \brief Function to suspend a SIMIX VM host. This function powers off the
+ * VM. All the processes on this VM will be killed. But, the state of the VM is
+ * perserved. We can later start it again.
+ *
+ * \param host the vm host to suspend (a smx_host_t)
+ */
+void SIMIX_vm_suspend(smx_host_t host)
+{
+  /* TODO: check state */
+
+  XBT_DEBUG("%lu processes in the VM", xbt_swag_size(SIMIX_host_priv(host)->process_list));
+
+  smx_process_t smx_process, smx_process_safe;
+  xbt_swag_foreach_safe(smx_process, smx_process_safe, SIMIX_host_priv(host)->process_list) {
+         XBT_DEBUG("suspend %s", SIMIX_host_get_name(host));
+         simcall_process_suspend(smx_process);
+  }
+
+  /* TODO: Using the variable of the MSG layer is not clean. */
+  SIMIX_set_vm_state(host, msg_vm_state_suspended);
+}
+
+void SIMIX_pre_vm_suspend(smx_simcall_t simcall, smx_host_t vm){
+   SIMIX_vm_suspend(vm);
+}
+
+/**
+ * \brief Function to shutdown a SIMIX VM host. This function powers off the
+ * VM. All the processes on this VM will be killed. But, the state of the VM is
+ * perserved. We can later start it again.
+ *
+ * \param host the vm host to shutdown (a smx_host_t)
+ */
+void SIMIX_vm_shutdown(smx_host_t host)
+{
+  /* TODO: check state */
+
+  XBT_DEBUG("%lu processes in the VM", xbt_swag_size(SIMIX_host_priv(host)->process_list));
+
+  smx_process_t smx_process, smx_process_safe;
+  xbt_swag_foreach_safe(smx_process, smx_process_safe, SIMIX_host_priv(host)->process_list) {
+         XBT_DEBUG("kill %s", SIMIX_host_get_name(host));
+         simcall_process_kill(smx_process);
+  }
+
+  /* TODO: Using the variable of the MSG layer is not clean. */
+  SIMIX_set_vm_state(host, msg_vm_state_sleeping);
+}
+
+void SIMIX_pre_vm_shutdown(smx_simcall_t simcall, smx_host_t vm){
+   SIMIX_vm_shutdown(vm);
+}
+
 /**
  * \brief Function to destroy a SIMIX VM host.
  *
@@ -104,6 +158,6 @@ void SIMIX_vm_destroy(smx_host_t ind_vm)
   surf_vm_workstation_model->extension.vm_workstation.destroy(ind_vm);
 }
 
-void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t ind_vm){
-   SIMIX_vm_destroy(ind_vm);
+void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t vm){
+   SIMIX_vm_destroy(vm);
 }
index e8f6a21..a76ca15 100644 (file)
@@ -98,7 +98,7 @@ void xbt_lib_unset(xbt_lib_t lib, const char *key, int level)
   }
 
   /* there is no element at any level, so delete the key */
-  xbt_dict_remove(lib->dict, key)
+  xbt_dict_remove(lib->dict, key);
 }
 
 void *xbt_lib_get_or_null(xbt_lib_t lib, const char *key, int level)