Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move VM state definition to a common header file
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Tue, 19 Feb 2013 12:18:17 +0000 (13:18 +0100)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Tue, 19 Feb 2013 12:18:17 +0000 (13:18 +0100)
include/msg/datatypes.h
include/simgrid/platf.h
src/msg/msg_vm.c
src/simix/smx_vm.c
src/surf/vm_workstation.c

index 8fca546..cf50969 100644 (file)
@@ -84,24 +84,6 @@ typedef struct msg_task *msg_task_t;
 typedef msg_host_t msg_vm_t;
 typedef msg_host_priv_t msg_vm_priv_t;
 
-/* must be synchronized with e_surf_vm_state_t */
-typedef enum {
-  /* created, but not yet started */
-  msg_vm_state_created,
-
-  msg_vm_state_running,
-  msg_vm_state_migrating,
-
-  /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
-  msg_vm_state_suspended,
-
-  /* Save/restore involves disk I/O, so there should be transition states. */
-  msg_vm_state_saving,
-  msg_vm_state_saved,
-  msg_vm_state_restoring,
-
-} e_msg_vm_state_t;
-
 static inline msg_vm_priv_t MSG_vm_priv(msg_vm_t vm){
   return xbt_lib_get_level(vm, MSG_HOST_LEVEL);
 }
index 49ad142..85b8505 100644 (file)
@@ -41,6 +41,25 @@ typedef enum {
 } e_surf_process_on_failure_t;
 
 
+/* FIXME: Where should the VM state be defined? */
+typedef enum {
+  /* created, but not yet started */
+  SURF_VM_STATE_CREATED,
+
+  SURF_VM_STATE_RUNNING,
+  SURF_VM_STATE_MIGRATING,
+
+  /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
+  SURF_VM_STATE_SUSPENDED,
+
+  /* Save/restore involves disk I/O, so there should be transition states. */
+  SURF_VM_STATE_SAVING,
+  SURF_VM_STATE_SAVED,
+  SURF_VM_STATE_RESTORING,
+
+} e_surf_vm_state_t;
+
+
 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
 
 /** opaque structure defining a event generator for availability based on a probability distribution */
index 38f98a0..ffb90b2 100644 (file)
@@ -94,7 +94,7 @@ const char *MSG_vm_get_name(msg_vm_t vm) {
 
 
 /* **** Check state of a VM **** */
-static inline int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) {
+static inline int __MSG_vm_is_state(msg_vm_t vm, e_surf_vm_state_t state) {
   return simcall_vm_get_state(vm) == state;
 }
 
@@ -103,7 +103,7 @@ static inline int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) {
  */
 int MSG_vm_is_created(msg_vm_t vm)
 {
-  return __MSG_vm_is_state(vm, vm_state_created);
+  return __MSG_vm_is_state(vm, SURF_VM_STATE_CREATED);
 }
 
 /** @brief Returns whether the given VM is currently running
@@ -111,7 +111,7 @@ int MSG_vm_is_created(msg_vm_t vm)
  */
 int MSG_vm_is_running(msg_vm_t vm)
 {
-  return __MSG_vm_is_state(vm, vm_state_running);
+  return __MSG_vm_is_state(vm, SURF_VM_STATE_RUNNING);
 }
 
 /** @brief Returns whether the given VM is currently migrating
@@ -119,7 +119,7 @@ int MSG_vm_is_running(msg_vm_t vm)
  */
 int MSG_vm_is_migrating(msg_vm_t vm)
 {
-  return __MSG_vm_is_state(vm, vm_state_migrating);
+  return __MSG_vm_is_state(vm, SURF_VM_STATE_MIGRATING);
 }
 
 /** @brief Returns whether the given VM is currently suspended, not running.
@@ -127,7 +127,7 @@ int MSG_vm_is_migrating(msg_vm_t vm)
  */
 int MSG_vm_is_suspended(msg_vm_t vm)
 {
-  return __MSG_vm_is_state(vm, vm_state_suspended);
+  return __MSG_vm_is_state(vm, SURF_VM_STATE_SUSPENDED);
 }
 
 /** @brief Returns whether the given VM is being saved (FIXME: live saving or not?).
@@ -135,7 +135,7 @@ int MSG_vm_is_suspended(msg_vm_t vm)
  */
 int MSG_vm_is_saving(msg_vm_t vm)
 {
-  return __MSG_vm_is_state(vm, vm_state_saving);
+  return __MSG_vm_is_state(vm, SURF_VM_STATE_SAVING);
 }
 
 /** @brief Returns whether the given VM has been saved, not running.
@@ -143,7 +143,7 @@ int MSG_vm_is_saving(msg_vm_t vm)
  */
 int MSG_vm_is_saved(msg_vm_t vm)
 {
-  return __MSG_vm_is_state(vm, vm_state_saved);
+  return __MSG_vm_is_state(vm, SURF_VM_STATE_SAVED);
 }
 
 /** @brief Returns whether the given VM is being restored, not running.
@@ -151,7 +151,7 @@ int MSG_vm_is_saved(msg_vm_t vm)
  */
 int MSG_vm_is_restoring(msg_vm_t vm)
 {
-  return __MSG_vm_is_state(vm, vm_state_restoring);
+  return __MSG_vm_is_state(vm, SURF_VM_STATE_RESTORING);
 }
 
 
index 6c566a6..fe93351 100644 (file)
@@ -80,7 +80,7 @@ void SIMIX_vm_start(smx_host_t ind_vm)
 {
   //TODO only start the VM if you can
   if (__can_be_started(ind_vm))
-    SIMIX_vm_set_state(ind_vm, msg_vm_state_running);
+    SIMIX_vm_set_state(ind_vm, SURF_VM_STATE_RUNNING);
   else
     THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm));
 }
@@ -122,12 +122,12 @@ void SIMIX_vm_migrate(smx_host_t ind_vm, smx_host_t ind_dst_pm)
   /* TODO: check state */
 
   /* TODO: Using the variable of the MSG layer is not clean. */
-  SIMIX_vm_set_state(ind_vm, msg_vm_state_migrating);
+  SIMIX_vm_set_state(ind_vm, SURF_VM_STATE_MIGRATING);
 
   /* jump to vm_ws_migrate(). this will update the vm location. */
   surf_vm_workstation_model->extension.vm_workstation.migrate(ind_vm, ind_dst_pm);
 
-  SIMIX_vm_set_state(ind_vm, msg_vm_state_running);
+  SIMIX_vm_set_state(ind_vm, SURF_VM_STATE_RUNNING);
 }
 
 void SIMIX_pre_vm_migrate(smx_simcall_t simcall, smx_host_t ind_vm, smx_host_t ind_dst_pm){
@@ -172,7 +172,7 @@ void SIMIX_vm_suspend(smx_host_t ind_vm)
   }
 
   /* TODO: Using the variable of the MSG layer is not clean. */
-  SIMIX_vm_set_state(ind_vm, msg_vm_state_suspended);
+  SIMIX_vm_set_state(ind_vm, SURF_VM_STATE_SUSPENDED);
 }
 
 void SIMIX_pre_vm_suspend(smx_simcall_t simcall, smx_host_t ind_vm){
@@ -200,7 +200,7 @@ void SIMIX_vm_resume(smx_host_t ind_vm)
   }
 
   /* TODO: Using the variable of the MSG layer is not clean. */
-  SIMIX_vm_set_state(ind_vm, msg_vm_state_running);
+  SIMIX_vm_set_state(ind_vm, SURF_VM_STATE_RUNNING);
 }
 
 void SIMIX_pre_vm_resume(smx_simcall_t simcall, smx_host_t ind_vm){
@@ -231,7 +231,7 @@ void SIMIX_vm_save(smx_host_t ind_vm)
   }
 
   /* TODO: Using the variable of the MSG layer is not clean. */
-  SIMIX_vm_set_state(ind_vm, msg_vm_state_saved);
+  SIMIX_vm_set_state(ind_vm, SURF_VM_STATE_SAVED);
 }
 
 void SIMIX_pre_vm_save(smx_simcall_t simcall, smx_host_t ind_vm){
@@ -261,7 +261,7 @@ void SIMIX_vm_restore(smx_host_t ind_vm)
   }
 
   /* TODO: Using the variable of the MSG layer is not clean. */
-  SIMIX_vm_set_state(ind_vm, msg_vm_state_running);
+  SIMIX_vm_set_state(ind_vm, SURF_VM_STATE_RUNNING);
 }
 
 void SIMIX_pre_vm_restore(smx_simcall_t simcall, smx_host_t ind_vm){
@@ -290,7 +290,7 @@ void SIMIX_vm_shutdown(smx_host_t ind_vm, smx_process_t issuer)
   }
 
   /* TODO: Using the variable of the MSG layer is not clean. */
-  SIMIX_vm_set_state(ind_vm, msg_vm_state_created);
+  SIMIX_vm_set_state(ind_vm, SURF_VM_STATE_CREATED);
 }
 
 void SIMIX_pre_vm_shutdown(smx_simcall_t simcall, smx_host_t ind_vm){
index 6358f9a..e1c0469 100644 (file)
 #include "surf/maxmin_private.h"
 
 
-/* FIXME: Where should the VM state be defined?
- * At now, this must be synchronized with e_msg_vm_state_t */
-typedef enum {
-  /* created, but not yet started */
-  vm_state_created,
-
-  vm_state_running,
-  vm_state_migrating,
-
-  /* Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
-  vm_state_suspended,
-
-  /* Save/restore involves disk I/O, so there should be transition states. */
-  vm_state_saving,
-  vm_state_saved,
-  vm_state_restoring,
-
-} e_surf_vm_state_t;
-
 /* NOTE:
  * The workstation_VM2013 struct includes the workstation_CLM03 struct in
  * its first member. The workstation_VM2013_t struct inherites all
@@ -66,7 +47,7 @@ static void vm_ws_create(const char *name, void *ind_phys_workstation)
   workstation_VM2013_t vm_ws = xbt_new0(s_workstation_VM2013_t, 1);
 
   vm_ws->sub_ws = surf_workstation_resource_priv(ind_phys_workstation);
-  vm_ws->current_state = vm_state_created;
+  vm_ws->current_state = SURF_VM_STATE_CREATED;
 
 
   // //// WORKSTATION  RELATED STUFF ////