Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
do cleanup around msg_vm_state_abc
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 7 Feb 2013 14:46:19 +0000 (15:46 +0100)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 7 Feb 2013 14:46:19 +0000 (15:46 +0100)
In the near future, some code related to VM state should be moved to the surf layer.

include/msg/datatypes.h
src/msg/msg_vm.c

index e5b3ea1..2738847 100644 (file)
@@ -106,14 +106,20 @@ typedef msg_host_t msg_vm_t;
 typedef msg_host_priv_t msg_vm_priv_t;
 
 typedef enum {
-msg_vm_state_created,
-msg_vm_state_running,
-msg_vm_state_sleeping,
-msg_vm_state_migrating,
-msg_vm_state_resuming,
-msg_vm_state_suspended,
-msg_vm_state_saved,
-msg_vm_state_restoring,
+  /* 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){
index 1bab452..6891726 100644 (file)
@@ -92,6 +92,73 @@ const char *MSG_vm_get_name(msg_vm_t vm) {
   return MSG_host_get_name(vm);
 }
 
+
+/* **** Check state of a VM **** */
+static inline int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) {
+  return simcall_vm_get_state(vm) == state;
+}
+
+/** @brief Returns whether the given VM has just reated, not running.
+ *  @ingroup msg_VMs
+ */
+int MSG_vm_is_created(msg_vm_t vm)
+{
+  return __MSG_vm_is_state(vm, msg_vm_state_created);
+}
+
+/** @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(vm, msg_vm_state_running);
+}
+
+/** @brief Returns whether the given VM is currently migrating
+ *  @ingroup msg_VMs
+ */
+int MSG_vm_is_migrating(msg_vm_t vm)
+{
+  return __MSG_vm_is_state(vm, msg_vm_state_migrating);
+}
+
+/** @brief Returns whether the given VM is currently suspended, not running.
+ *  @ingroup msg_VMs
+ */
+int MSG_vm_is_suspended(msg_vm_t vm)
+{
+  return __MSG_vm_is_state(vm, msg_vm_state_suspended);
+}
+
+/** @brief Returns whether the given VM is being saved (FIXME: live saving or not?).
+ *  @ingroup msg_VMs
+ */
+int MSG_vm_is_saving(msg_vm_t vm)
+{
+  return __MSG_vm_is_state(vm, msg_vm_state_saving);
+}
+
+/** @brief Returns whether the given VM has been saved, not running.
+ *  @ingroup msg_VMs
+ */
+int MSG_vm_is_saved(msg_vm_t vm)
+{
+  return __MSG_vm_is_state(vm, msg_vm_state_saved);
+}
+
+/** @brief Returns whether the given VM is being restored, not running.
+ *  @ingroup msg_VMs
+ */
+int MSG_vm_is_restoring(msg_vm_t vm)
+{
+  return __MSG_vm_is_state(vm, msg_vm_state_restoring);
+}
+
+
+
+/* ------------------------------------------------------------------------- */
+/* ------------------------------------------------------------------------- */
+
 /* **** ******** MSG vm actions ********* **** */
 
 /** @brief Create a new VM (the VM is just attached to the location but it is not started yet).
@@ -140,25 +207,6 @@ void MSG_vm_start(msg_vm_t vm) {
   #endif
 }
 
-/* **** Check state of a VM **** */
-int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) {
-       return simcall_vm_get_state(vm) == state ;
-}
-
-/** @brief Returns whether the given VM is currently suspended
- *  @ingroup msg_VMs
- */
-int MSG_vm_is_suspended(msg_vm_t vm) {
-       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(vm, msg_vm_state_running);
-}
-
-// TODO Implement the functions for the different state
 
 
 /** @brief Immediately kills all processes within the given VM. Any memory that they allocated will be leaked.