Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add get_phys_host, which enables us to pick up private data at any layer
authorTakahiro Hirofuchi <thirofuchi@debian.(none)>
Mon, 4 Feb 2013 11:35:10 +0000 (12:35 +0100)
committerTakahiro Hirofuchi <thirofuchi@debian.(none)>
Mon, 4 Feb 2013 11:35:10 +0000 (12:35 +0100)
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/surf/vm_workstation.c

index fe18a39..efed718 100644 (file)
@@ -283,6 +283,7 @@ typedef struct surf_vm_workstation_model_extension_public {
   int (*get_state) (void *ind_vm_workstation);
   void (*set_state) (void *ind_vms_workstation, int state);
   void (*migrate) (void *ind_vm_workstation, void *ind_dest_phys_workstation); // will be vm_ws_migrate()
+  const char * (*get_phys_host) (void *ind_vm_workstation); // will be vm_ws_get_phys_host()
   void (*destroy) (void *ind_vm_workstation); // will be vm_ws_destroy(), which destroies the vm-workstation-specific data
 } s_surf_model_extension_vm_workstation_t;
 
index ec1fd3d..d206d40 100644 (file)
@@ -248,7 +248,7 @@ void MSG_vm_migrate(msg_vm_t vm, msg_host_t destination)
   simcall_vm_migrate(vm, destination);
 
   #ifdef HAVE_TRACING
-  TRACE_msg_vm_change_host(vm,vm->location,destination);
+  // TRACE_msg_vm_change_host(vm, vm->location, destination);
   #endif
 
 #if 0
index f639f16..4d63029 100644 (file)
@@ -279,6 +279,7 @@ 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_MIGRATE, vm_migrate, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t), TSPEC(ind_dst_pm, smx_host_t)) sep \
+ACTION(SIMCALL_VM_GET_PHYS_HOST, vm_get_phys_host, WITH_ANSWER, TSTRING(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_RESUME, vm_resume, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t)) sep \
index 7c93b72..bfc9a3e 100644 (file)
@@ -290,10 +290,10 @@ void simcall_vm_start(smx_host_t vm) {
   simcall_BODY_set_vm_state(vm, msg_vm_state_running);
 }
 
-void simcall_vm_migrate(smx_host_t vm)
+void simcall_vm_migrate(smx_host_t vm, smx_host_t dst_phys)
 {
   /* will jump to SIMIX_pre_vm_migrate */
-  simcall_BODY_vm_migrate(vm);
+  simcall_BODY_vm_migrate(vm, dst_phys);
 }
 
 void simcall_vm_suspend(smx_host_t vm)
index 0ee8918..cd1a29a 100644 (file)
@@ -96,8 +96,8 @@ void SIMIX_vm_migrate(smx_host_t ind_vm, smx_host_t ind_dst_pm)
   /* TODO: Using the variable of the MSG layer is not clean. */
   SIMIX_set_vm_state(ind_vm, msg_vm_state_migrating);
 
-  /* jump to vm_ws_destroy(). this will update the vm location. */
-  surf_vm_workstation_model->extension.vm_workstation.migrate(ind_vm, ind_dst);
+  /* 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_set_vm_state(ind_vm, msg_vm_state_running);
 }
@@ -106,6 +106,21 @@ void SIMIX_pre_vm_migrate(smx_simcall_t simcall, smx_host_t ind_vm, smx_host_t i
    SIMIX_vm_migrate(ind_vm, ind_dst_pm);
 }
 
+/**
+ * \brief Function to get the physical host of the given the SIMIX VM host.
+ *
+ * \param host the vm host to get_phys_host (a smx_host_t)
+ */
+const char *SIMIX_vm_get_phys_host(smx_host_t ind_vm)
+{
+  /* jump to vm_ws_get_phys_host(). this will update the vm location. */
+  return surf_vm_workstation_model->extension.vm_workstation.get_phys_host(ind_vm);
+}
+
+const char *SIMIX_pre_vm_get_phys_host(smx_simcall_t simcall, smx_host_t ind_vm){
+  return SIMIX_vm_get_phys_host(ind_vm);
+}
+
 /**
  * \brief Function to suspend a SIMIX VM host. This function stops the exection of the
  * VM. All the processes on this VM will pause. The state of the VM is
@@ -154,7 +169,7 @@ void SIMIX_vm_resume(smx_host_t ind_vm)
   }
 
   /* TODO: Using the variable of the MSG layer is not clean. */
-  SIMIX_set_vm_state(ind_vm, msg_vm_state_resumeed);
+  SIMIX_set_vm_state(ind_vm, msg_vm_state_running);
 }
 
 void SIMIX_pre_vm_resume(smx_simcall_t simcall, smx_host_t ind_vm){
index 23a287b..cc34c9c 100644 (file)
@@ -44,7 +44,7 @@ static void vm_ws_migrate(void *ind_vm_workstation, void *ind_dest_phys_workstat
    xbt_assert(vm_ws);
 
    /* do something */
-   
+
    vm_ws->physical_workstation = surf_workstation_resource_priv(ind_dest_phys_workstation);
 }
 
@@ -74,6 +74,17 @@ static int vm_ws_get_state(void *ind_vm_ws){
 static void vm_ws_set_state(void *ind_vm_ws, int state){
         ((workstation_VM2013_t) surf_workstation_resource_priv(ind_vm_ws))->current_state=state;
 }
+
+/*
+ * A surf level object will be useless in the upper layer. Returing the name
+ * will be simple and suffcient.
+ **/
+static const char *vm_ws_get_phys_host(void *ind_vm_ws)
+{
+       workstation_VM2013_t vm_ws = surf_workstation_resource_priv(ind_vm_ws);
+       return vm_ws->physical_workstation->name;
+}
+
 static void surf_vm_workstation_model_init_internal(void)
 {
   surf_vm_workstation_model = surf_model_init();
@@ -84,6 +95,7 @@ static void surf_vm_workstation_model_init_internal(void)
   surf_vm_workstation_model->extension.vm_workstation.set_state = vm_ws_set_state;
   surf_vm_workstation_model->extension.vm_workstation.get_state = vm_ws_get_state;
   surf_vm_workstation_model->extension.vm_workstation.migrate = vm_ws_migrate;
+  surf_vm_workstation_model->extension.vm_workstation.get_phys_host = vm_ws_get_phys_host;
   surf_vm_workstation_model->extension.vm_workstation.destroy = vm_ws_destroy;
 
 }