XBT_PUBLIC(void) simcall_host_execution_set_priority(smx_action_t execution, double priority);
XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
+/******************************* 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_start(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_suspend(smx_host_t vm);
+XBT_PUBLIC(void) simcall_vm_destroy(smx_host_t vm);
/**************************** Process simcalls ********************************/
/* Constructor and Destructor */
}
}
+void TRACE_msg_vm_start (msg_vm_t vm)
+{
+ if (TRACE_msg_vm_is_enabled()){
+ int len = INSTR_DEFAULT_STR_SIZE;
+ char str[INSTR_DEFAULT_STR_SIZE];
+
+ container_t vm_container = PJ_container_get (instr_vm_id(vm, str, len));
+ type_t type = PJ_type_get ("MSG_VM_STATE", vm_container->type);
+ val_t value = PJ_value_get ("start", type);
+ new_pajePushState (MSG_get_clock(), vm_container, type, value);
+ }
+
+}
+
void TRACE_msg_vm_kill(msg_vm_t vm) {
if (TRACE_msg_vm_is_enabled()) {
int len = INSTR_DEFAULT_STR_SIZE;
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+
+// TODO
+// 1./ check how and where a new VM is added to the list of the hosts
+// 2./ MSG_TRACE can be revisited in order to use the host
+
+
#include "msg_private.h"
#include "xbt/sysdep.h"
#include "xbt/log.h"
return MSG_host_get_name(vm);
}
-/** @brief Returns a newly constructed dynar containing all existing VMs in the system.
- * @ingroup msg_VMs
- *
- * Don't forget to free the dynar after use.
- */
-xbt_dynar_t MSG_vms_as_dynar(void) {
- xbt_dynar_t res = xbt_dynar_new(sizeof(msg_vm_t),NULL);
- msg_vm_t vm;
- xbt_swag_foreach(vm,msg_global->vms) {
- xbt_dynar_push(res,&vm);
- }
- return res;
-}
-
/* **** ******** MSG vm actions ********* **** */
/** @brief Create a new VM (the VM is just attached to the location but it is not started yet).
* Please note that a VM is a specific host. Hence, you should give a different name
* for each VM/PM.
*/
-msg_vm_t MSG_vm_create(msg_host_t location, const char *name,
+msg_vm_t MSG_vm_create(msg_host_t ind_host, const char *name,
int core_nb, int mem_cap, int net_cap){
// Note new and vm_workstation refer to the same area (due to the lib/dict appraoch)
msg_vm_t new = NULL;
- void *vm_workstation = NULL;
+ void *ind_vm_workstation = NULL;
// Ask simix to create the surf vm resource
- vm_workstation = simcall_vm_create(name,location);
- new = (msg_vm_t) __MSG_host_create(vm_workstation);
+ ind_vm_workstation = simcall_vm_ws_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);
MSG_vm_set_property_value(new, "MEM_CAP", bprintf("%d", core_nb), free);
// TODO check whether the vm (i.e the virtual host) has been correctly added into the list of all hosts.
#ifdef HAVE_TRACING
- TRACE_msg_vm_create(name, location);
+ TRACE_msg_vm_create(name, ind_host);
#endif
return new;
* @ingroup msg_VMs
*/
int MSG_vm_is_suspended(msg_vm_t vm) {
- return __MSG_vm_is_state(msg_vm_state_suspended);
+ 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(msg_vm_state_running);
+ return __MSG_vm_is_state(vm, msg_vm_state_running);
}
// TODO Implement the functions for the different state
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_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(phys_host, smx_host_t)) sep \
-ACTION(SIMCALL_VM_SET_STATE, vm_set_state, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_t), TINT(state)) sep \
-ACTION(SIMCALL_VM_GET_STATE, vm_get_state, WITH_ANSWER, TINT(result), TSPEC(vm, smx_host_t)) sep \
-ACTION(SIMCALL_VM_DESTROY, vm_destroy, WITHOUT_ANSWER, TVOID(result), TSPEC(vm, smx_host_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_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 \
+ACTION(SIMCALL_VM_DESTROY, vm_destroy, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t)) sep \
ACTION(SIMCALL_PROCESS_CREATE, process_create, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t*), TSTRING(name), TSPEC(code, xbt_main_func_t), TPTR(data), TSTRING(hostname), TDOUBLE(kill_time), TINT(argc), TSPEC(argv, char**), TSPEC(properties, xbt_dict_t), TINT(auto_restart)) sep \
ACTION(SIMCALL_PROCESS_KILL, process_kill, WITH_ANSWER, TVOID(result), TSPEC(process, smx_process_t)) sep \
ACTION(SIMCALL_PROCESS_KILLALL, process_killall, WITH_ANSWER, TVOID(result)) sep \
* \param host A host
* \return The properties of this host
*/
-void* simcall_vm_create(const char *name, smx_host_t phys_host){
-{
- return simcall_BODY_vm_create(name, phys_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_start(smx_host_t vm){
+void simcall_vm_start(smx_host_t vm) {
simcall_BODY_set_vm_state(vm, msg_vm_state_running);
}
-void simcall_vm_destroy(smx_host_t vm)
-{
- return simcall_BODY_vm_destroy(vm);
+void simcall_vm_destroy(smx_host_t vm) {
+ simcall_BODY_vm_destroy(vm);
}
/**
#include "xbt/dict.h"
#include "mc/mc.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix,
- "Logging specific to SIMIX (vms)");
+//If you need to log some stuffs, just uncomment these two lines and uses XBT_DEBUG for instance
+//XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix,
+// "Logging specific to SIMIX (vms)");
+
/* **** create a VM **** */
/**
* \param name name of the host to create
* \param data some user data (may be NULL)
*/
-smx_host_t SIMIX_vm_create(const char *name, smx_host_t phys_host)
+smx_host_t SIMIX_vm_create(const char *name, smx_host_t ind_phys_host)
{
smx_host_priv_t smx_host = xbt_new0(s_smx_host_priv_t, 1);
/* Create surf associated resource */
// TODO change phys_host into the right workstation surf model
- surf_vm_workstation_model->extension.vm_workstation.create(name, phys_host);
+ surf_vm_workstation_model->extension.vm_workstation.create(name, ind_phys_host);
return xbt_lib_get_elm_or_null(host_lib, name);
}
-smx_host_t SIMIX_pre_vm_create(smx_simcall_t simcall, const char *name, smx_host_t phys_host){
- return SIMIX_vm_create(name, phys_host);
+smx_host_t SIMIX_pre_vm_create(smx_simcall_t simcall, const char *name, smx_host_t ind_phys_host){
+ return SIMIX_vm_create(name, ind_phys_host);
}
// TODO add checking code related to overcommitment or not.
return 1;
}
-void SIMIX_vm_start(smx_host_t vm){
+void SIMIX_vm_start(smx_host_t ind_vm){
//TODO only start the VM if you can
- if (can_be_started(vm))
- SIMIX_set_vm_state(vm, msg_vm_state_running);
+ if (can_be_started(ind_vm))
+ SIMIX_set_vm_state(ind_vm, msg_vm_state_running);
else
- THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(vm));
+ THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm));
}
-void SIMIX_pre_vm_start(smx_simcall_t simcall, smx_host_t vm){
+void SIMIX_pre_vm_start(smx_simcall_t simcall, smx_host_t ind_vm){
SIMIX_vm_start(vm);
}
/* ***** set/get state of a VM ***** */
-void SIMIX_set_vm_state(smx_host_t vm, int state){
- surf_vm_workstation_model->extension.vm_workstation.set_state(vm, state);
+void SIMIX_set_vm_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 vm, int state){
- SIMIX_set_vm_state(vm, state);
+void SIMIX_prev_set_vm_state(smx_host_t ind_vm, int state){
+ SIMIX_set_vm_state(ind_vm, state);
}
-int SIMIX_get_vm_state(smx_host_t vm){
- return surf_vm_workstation_model->extension.vm_workstation.get_state(vm);
+int SIMIX_get_vm_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 vm){
- return SIMIX_get_vm_state(vm);
+int SIMIX_pre_vm_state(smx_host_t ind_vm){
+ return SIMIX_get_vm_state(ind_vm);
}
/**
*
* \param host the vm host to destroy (a smx_host_t)
*/
-void SIMIX_vm_destroy(smx_host_t host)
+void SIMIX_vm_destroy(smx_host_t ind_vm)
{
/* this code basically performs a similar thing like SIMIX_host_destroy() */
xbt_assert((host != NULL), "Invalid parameters");
- char *hostname = host->key;
+ char *hostname = SIMIX_host_get_name(ind_vm);
smx_host_priv_t host_priv = SIMIX_host_priv(host);
xbt_lib_unset(host_lib, hostname, SIMIX_HOST_LEVEL);
/* jump to vm_ws_destroy(). The surf level resource will be freed. */
- surf_vm_workstation_model->extension.vm_workstation.destroy(host);
+ surf_vm_workstation_model->extension.vm_workstation.destroy(ind_vm);
}
-void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t vm){
- SIMIX_vm_start(vm);
+void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t ind_vm){
+ SIMIX_vm_destroy(ind_vm);
}