/******************************* VM simcalls ********************************/
// Create the vm_workstation at the SURF level
-XBT_PUBLIC(void*) simcall_vm_ws_create(const char *name, smx_host_t host);
-XBT_PUBLIC(void*) simcall_get_vm_state(smx_host_t vm);
+XBT_PUBLIC(void*) simcall_vm_create(const char *name, smx_host_t host);
+XBT_PUBLIC(int) simcall_vm_get_state(smx_host_t vm);
XBT_PUBLIC(void) simcall_vm_start(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_migrate(smx_host_t vm, smx_host_t dst_pm);
+XBT_PUBLIC(const char*) simcall_vm_get_phys_host(smx_host_t vm);
XBT_PUBLIC(void) simcall_vm_suspend(smx_host_t vm);
XBT_PUBLIC(void) simcall_vm_destroy(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_shutdown(smx_host_t vm);
/**************************** Process simcalls ********************************/
/* Constructor and Destructor */
char *instr_vm_id (msg_vm_t vm, char *str, int len)
{
- return instr_vm_id_2 (MSG_get_vm_name(vm), str, len);
+ return instr_vm_id_2 (MSG_vm_get_name(vm), str, len);
}
char *instr_vm_id_2 (const char *vm_name, char *str, int len)
msg_vm_t new = NULL;
void *ind_vm_workstation = NULL;
// Ask simix to create the surf vm resource
- ind_vm_workstation = simcall_vm_ws_create(name,ind_host);
+ ind_vm_workstation = simcall_vm_create(name,ind_host);
new = (msg_vm_t) __MSG_host_create(ind_vm_workstation);
MSG_vm_set_property_value(new, "CORE_NB", bprintf("%d", core_nb), free);
/* **** Check state of a VM **** */
int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) {
- return simcall_get_vm_state(vm) == state ;
+ return simcall_vm_get_state(vm) == state ;
}
/** @brief Returns whether the given VM is currently suspended
void SIMIX_vm_start(smx_host_t ind_vm);
void SIMIX_pre_vm_start(smx_simcall_t simcall, smx_host_t ind_vm);
-void SIMIX_set_vm_state(smx_host_t ind_vm, int state);
-void SIMIX_prev_set_vm_state(smx_host_t ind_vm, int state);
+void SIMIX_vm_set_state(smx_host_t ind_vm, int state);
+void SIMIX_prev_vm_set_state(smx_host_t ind_vm, int state);
-int SIMIX_get_vm_state(smx_host_t ind_vm);
+int SIMIX_vm_get_state(smx_host_t ind_vm);
int SIMIX_pre_vm_state(smx_host_t ind_vm);
void SIMIX_vm_suspend(smx_host_t ind_vm);
ACTION(SIMCALL_HOST_EXECUTION_GET_STATE, host_execution_get_state, WITH_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
ACTION(SIMCALL_HOST_EXECUTION_SET_PRIORITY, host_execution_set_priority, WITH_ANSWER, TVOID(result), TSPEC(execution, smx_action_t), TDOUBLE(priority)) sep \
ACTION(SIMCALL_HOST_EXECUTION_WAIT, host_execution_wait, WITHOUT_ANSWER, TINT(result), TSPEC(execution, smx_action_t)) sep \
-ACTION(SIMCALL_VM_WS_CREATE, vm_ws_create, WITH_ANSWER, TPTR(result), TSTRING(name), TSPEC(phys_host, smx_host_t)) sep \
+ACTION(SIMCALL_VM_CREATE, vm_create, WITH_ANSWER, TPTR(result), TSTRING(name), TSPEC(phys_host, smx_host_t)) sep \
ACTION(SIMCALL_VM_START, vm_start, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_phys_host, smx_host_t)) sep \
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 \
* \param host A host
* \return The properties of this host
*/
-void* simcall_vm_ws_create(const char *name, smx_host_t phys_host){
- return simcall_BODY_vm_ws_create(name, phys_host);
+void* simcall_vm_create(const char *name, smx_host_t phys_host){
+ /* jump to SIMIX_pre_vm_create() */
+ return simcall_BODY_vm_create(name, phys_host);
}
void simcall_vm_start(smx_host_t vm) {
- simcall_BODY_set_vm_state(vm, msg_vm_state_running);
+ simcall_BODY_vm_set_state(vm, msg_vm_state_running);
+}
+
+int simcall_vm_get_state(smx_host_t vm)
+{
+ /* will jump to SIMIX_pre_vm_get_state */
+ return simcall_BODY_vm_get_state(vm);
}
void simcall_vm_migrate(smx_host_t vm, smx_host_t dst_phys)
/* **** start a VM **** */
-int __can_be_started(smx_host_t vm){
+static int __can_be_started(smx_host_t vm){
// TODO add checking code related to overcommitment or not.
return 1;
}
void SIMIX_vm_start(smx_host_t ind_vm){
//TODO only start the VM if you can
- if (can_be_started(ind_vm))
- SIMIX_set_vm_state(ind_vm, msg_vm_state_running);
+ if (__can_be_started(ind_vm))
+ SIMIX_vm_set_state(ind_vm, msg_vm_state_running);
else
THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm));
}
}
/* ***** set/get state of a VM ***** */
-void SIMIX_set_vm_state(smx_host_t ind_vm, int state){
+void SIMIX_vm_set_state(smx_host_t ind_vm, int state){
surf_vm_workstation_model->extension.vm_workstation.set_state(ind_vm, state);
}
-void SIMIX_prev_set_vm_state(smx_host_t ind_vm, int state){
- SIMIX_set_vm_state(ind_vm, state);
+void SIMIX_pre_vm_set_state(smx_host_t ind_vm, int state){
+ SIMIX_vm_set_state(ind_vm, state);
}
-int SIMIX_get_vm_state(smx_host_t ind_vm){
+int SIMIX_vm_get_state(smx_host_t ind_vm){
return surf_vm_workstation_model->extension.vm_workstation.get_state(ind_vm);
}
-int SIMIX_pre_vm_state(smx_host_t ind_vm){
- return SIMIX_get_vm_state(ind_vm);
+int SIMIX_pre_vm_get_state(smx_host_t ind_vm){
+ return SIMIX_vm_get_state(ind_vm);
}
/**
/* TODO: check state */
/* TODO: Using the variable of the MSG layer is not clean. */
- SIMIX_set_vm_state(ind_vm, msg_vm_state_migrating);
+ SIMIX_vm_set_state(ind_vm, msg_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_set_vm_state(ind_vm, msg_vm_state_running);
+ SIMIX_vm_set_state(ind_vm, msg_vm_state_running);
}
void SIMIX_pre_vm_migrate(smx_simcall_t simcall, 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_suspended);
+ SIMIX_vm_set_state(ind_vm, msg_vm_state_suspended);
}
void SIMIX_pre_vm_suspend(smx_simcall_t simcall, 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_running);
+ SIMIX_vm_set_state(ind_vm, msg_vm_state_running);
}
void SIMIX_pre_vm_resume(smx_simcall_t simcall, 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_sleeping);
+ SIMIX_vm_set_state(ind_vm, msg_vm_state_sleeping);
}
void SIMIX_pre_vm_shutdown(smx_simcall_t simcall, smx_host_t ind_vm){