Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix msg_vm_shutdown
authorTakahiro Hirofuchi <thirofuchi@debian.(none)>
Thu, 31 Jan 2013 21:44:29 +0000 (22:44 +0100)
committerTakahiro Hirofuchi <thirofuchi@debian.(none)>
Thu, 31 Jan 2013 21:44:29 +0000 (22:44 +0100)
include/msg/datatypes.h
src/msg/msg_vm.c
src/simix/smx_user.c
src/simix/smx_vm.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 ad6a474..aebd0c3 100644 (file)
@@ -164,11 +164,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
-
 }
 
 
index f9cad2c..79a9fb1 100644 (file)
@@ -292,6 +292,12 @@ void simcall_vm_start(smx_host_t 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)
 {
   /* will jump to SIMIX_pre_vm_destroy */
index 8d82b17..7429d96 100644 (file)
@@ -81,6 +81,33 @@ int SIMIX_pre_vm_state(smx_host_t vm){
        return SIMIX_get_vm_state(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(smx_host)->process_list));
+
+  xbt_swag_foreach_safe(smx_process, SIMIX_host_priv(smx_host)->process_list) {
+         XBT_DEBUG("kill %s", SIMIX_host_get_name(smx_host));
+         simcall_process_kill(smx_process);
+  }
+
+  /* TODO: Using the variable of the MSG layer is not clean. */
+  SIMIX_set_vm_state(vm, 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.
  *