Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
migration: fix status check of migration
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Wed, 16 Jul 2014 07:04:53 +0000 (16:04 +0900)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Wed, 16 Jul 2014 07:04:53 +0000 (16:04 +0900)
When a migration of a VM is already ongoing, do not allow
MSG_vm_migrate() for the VM.

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

index 760a2d8..8f629c6 100644 (file)
@@ -51,6 +51,7 @@ typedef struct msg_host_priv {
   int        dp_enabled;
   xbt_dict_t dp_objs;
   double     dp_updated_by_deleted_tasks;
+  int        is_migrating;
 
   xbt_dict_t affinity_mask_db;
 
index fc02148..4210fc9 100644 (file)
@@ -171,16 +171,12 @@ typedef enum {
 /* FIXME: Where should the VM state be defined? */
 typedef enum {
   SURF_VM_STATE_CREATED, /**< created, but not yet started */
-
   SURF_VM_STATE_RUNNING,
-  SURF_VM_STATE_MIGRATING,
-
   SURF_VM_STATE_SUSPENDED, /**< Suspend/resume does not involve disk I/O, so we assume there is no transition states. */
 
   SURF_VM_STATE_SAVING, /**< Save/restore involves disk I/O, so there should be transition states. */
   SURF_VM_STATE_SAVED,
   SURF_VM_STATE_RESTORING,
-
 } e_surf_vm_state_t;
 
 /***************************/
index 00e126c..4940e29 100644 (file)
@@ -51,6 +51,7 @@ msg_host_t __MSG_host_create(smx_host_t workstation)
   priv->dp_objs = xbt_dict_new();
   priv->dp_enabled = 0;
   priv->dp_updated_by_deleted_tasks = 0;
+  priv->is_migrating = 0;
 
   priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL);
 
index ba12a24..bf45c22 100644 (file)
@@ -124,7 +124,8 @@ int MSG_vm_is_running(msg_vm_t vm)
  */
 int MSG_vm_is_migrating(msg_vm_t vm)
 {
-  return __MSG_vm_is_state(vm, SURF_VM_STATE_MIGRATING);
+  msg_host_priv_t priv = msg_host_resource_priv(vm);
+  return priv->is_migrating;
 }
 
 /** @brief Returns whether the given VM is currently suspended, not running.
@@ -238,6 +239,9 @@ msg_vm_t MSG_vm_create_core(msg_host_t ind_pm, const char *name)
  */
 void MSG_vm_destroy(msg_vm_t vm)
 {
+  if (MSG_vm_is_migrating(vm))
+    THROWF(vm_error, 0, "VM(%s) is migrating", sg_host_name(vm));
+
   /* First, terminate all processes on the VM if necessary */
   if (MSG_vm_is_running(vm))
       simcall_vm_shutdown(vm);
@@ -1135,12 +1139,18 @@ void MSG_vm_migrate(msg_vm_t vm, msg_host_t new_pm)
 
   msg_host_t old_pm = simcall_vm_get_pm(vm);
 
-  if (simcall_vm_get_state(vm) != SURF_VM_STATE_RUNNING)
+  if (!MSG_vm_is_running(vm))
     THROWF(vm_error, 0, "VM(%s) is not running", sg_host_name(vm));
 
-  do_migration(vm, old_pm, new_pm);
+  if (MSG_vm_is_migrating(vm))
+    THROWF(vm_error, 0, "VM(%s) is already migrating", sg_host_name(vm));
+
+  msg_host_priv_t priv = msg_host_resource_priv(vm);
+  priv->is_migrating = 1;
 
+  do_migration(vm, old_pm, new_pm);
 
+  priv->is_migrating = 0;
 
   XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", vm->key, old_pm->key, new_pm->key);
 
@@ -1160,6 +1170,9 @@ void MSG_vm_migrate(msg_vm_t vm, msg_host_t new_pm)
  */
 void MSG_vm_suspend(msg_vm_t vm)
 {
+  if (MSG_vm_is_migrating(vm))
+    THROWF(vm_error, 0, "VM(%s) is migrating", sg_host_name(vm));
+
   simcall_vm_suspend(vm);
 
   XBT_DEBUG("vm_suspend done");
@@ -1197,6 +1210,9 @@ void MSG_vm_resume(msg_vm_t vm)
  */
 void MSG_vm_save(msg_vm_t vm)
 {
+  if (MSG_vm_is_migrating(vm))
+    THROWF(vm_error, 0, "VM(%s) is migrating", sg_host_name(vm));
+
   simcall_vm_save(vm);
   #ifdef HAVE_TRACING
   TRACE_msg_vm_save(vm);