typedef s_xbt_dictelm_t s_msg_host_t;
typedef struct msg_host_priv {
- xbt_swag_t vms;
+
+ // TODO Warning keeping such vms attribut may lead to some complexity at the SURF Level.
+ // Please check with Arnaud
+ xbt_dynar_t vms;
#ifdef MSG_USE_DEPRECATED
msg_mailbox_t *mailboxes; /**< the channels */
#endif
*/
typedef struct msg_task *msg_task_t;
+/* ******************************** Hypervisor ************************************* */
+typedef struct msg_hypervisor *msg_hypervisor_t;
+
+typedef struct msg_hypervisor {
+ const char *name;
+ s_xbt_swag_hookup_t all_hypervisor_hookup;
+ xbt_dynar_t vms; // vms on this hypervisor
+ msg_host_t host; // physical host of this hypervisor
+
+ /* The hypervisor object does not have parameters like the number of CPU
+ Ê * cores and the size of memory. These parameters come from those of the
+ Ê * physical host.
+ Ê **/
+ int overcommit;
+
+} s_msg_hypervisor_t;
+
/* ******************************** VM ************************************* */
-typedef struct msg_vm *msg_vm_t;
+typedef msg_host_t msg_vm_t;
+/* todo: make it clear */
typedef enum {
- msg_vm_state_suspended, msg_vm_state_running, msg_vm_state_migrating
+msg_vm_state_created,
+msg_vm_state_booting,
+msg_vm_state_running,
+msg_vm_state_sleeping,
+msg_vm_state_migrating,
+msg_vm_state_resuming,
+msg_vm_state_suspending,
+msg_vm_state_saving,
+msg_vm_state_restoring,
} e_msg_vm_state_t;
-typedef struct msg_vm {
- const char *name;
- s_xbt_swag_hookup_t all_vms_hookup;
- s_xbt_swag_hookup_t host_vms_hookup;
- xbt_dynar_t processes;
- e_msg_vm_state_t state;
- msg_host_t location;
- int coreAmount;
-} s_msg_vm_t;
+
/* ******************************** File ************************************ */
typedef struct simdata_file *simdata_file_t;
*
*/
/* This function should not be called directly, but rather from MSG_vm_start_from_template that does not exist yet*/
-XBT_PUBLIC(msg_vm_t) MSG_vm_start(msg_host_t location, const char *name, int coreAmount);
+
+// TODO add VDI later
+XBT_PUBLIC(msg_vm_t) MSG_vm_create(msg_host_t location, const char *name,
+ int core_nb, int mem_cap, int net_cap);
+
+XBT_PUBLIC(int) MSG_vm_start(msg_vm_t);
XBT_PUBLIC(int) MSG_vm_is_suspended(msg_vm_t);
XBT_PUBLIC(int) MSG_vm_is_running(msg_vm_t);
} s_surf_model_extension_workstation_t;
-
-
+typedef struct surf_vm_workstation_model_extension_public {
+ s_surf_model_extension_workstation_t basic;
+ void* (*create) (const char *name, void *workstation); // First operation of the VM model
+} s_surf_model_extension_vm_workstation_t;
/** \ingroup SURF_models
* \brief Model datatype
s_surf_model_extension_network_t network;
s_surf_model_extension_storage_t storage;
s_surf_model_extension_workstation_t workstation;
+ // TODO Implement the corresponding model
+ s_surf_model_extension_vm_workstation_t vm_workstation;
/*******************************************/
/* TUTORIAL: New model */
s_surf_model_extension_new_model_t new_model;
{
const char *name = SIMIX_host_get_name(workstation);
msg_host_priv_t host = xbt_new0(s_msg_host_priv_t, 1);
- s_msg_vm_t vm; // simply to compute the offset
- host->vms = xbt_swag_new(xbt_swag_offset(vm,host_vms_hookup));
+ host->vms = xbt_dynar_new(sizeof(msg_vm_t),NULL);
#ifdef MSG_USE_DEPRECATED
int i;
* to add extra constraints on the execution, but the argument is ignored for now.
*/
-msg_vm_t MSG_vm_start(msg_host_t location, const char *name, int coreAmount) {
- msg_vm_t res = xbt_new0(s_msg_vm_t,1);
- res->all_vms_hookup.prev = NULL;
- res->host_vms_hookup.prev = NULL;
- res->state = msg_vm_state_running;
- res->location = location;
- res->coreAmount = coreAmount;
- res->name = xbt_strdup(name);
- res->processes = xbt_dynar_new(sizeof(msg_process_t),NULL);
-
- xbt_swag_insert(res,msg_global->vms);
- xbt_swag_insert(res, MSG_host_priv(location)->vms);
+msg_vm_t MSG_vm_create(msg_host_t location, 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;
+ // Ask simix to create the surf vm resource
+ vm_workstation = simcall_vm_create(name,location);
+ new = (msg_vm_t) __MSG_host_create(vm_workstation);
+
+
+ MSG_vm_set_property_value(new, "CORE_NB", bprintf("%d", core_nb)), NULL);
+ MSG_vm_set_property_value(new, "MEM_CAP", bprintf("%d", core_nb)), NULL);
+ MSG_vm_set_property_value(new, "NET_CAP", bprintf("%d", core_nb)), NULL);
#ifdef HAVE_TRACING
TRACE_msg_vm_create(name, location);
#endif
+ return new;
+}
+
+/** \ingroup m_host_management
+ * \brief Returns the value of a given host property
+ *
+ * \param host a host
+ * \param name a property name
+ * \return value of a property (or NULL if property not set)
+ */
+const char *MSG_host_get_property_value(msg_host_t host, const char *name)
+{
+ return xbt_dict_get_or_null(MSG_host_get_properties(host), name);
+}
+/** \ingroup m_host_management
+ * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this host
+ *
+ * \param host a host
+ * \return a dict containing the properties
+ */
+xbt_dict_t MSG_host_get_properties(msg_host_t host)
+{
+ xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
- return res;
+ return (simcall_host_get_properties(host));
+}
+
+/** \ingroup m_host_management
+ * \brief Change the value of a given host property
+ *
+ * \param host a host
+ * \param name a property name
+ * \param value what to change the property to
+ * \param free_ctn the freeing function to use to kill the value on need
+ */
+void MSG_vm_set_property_value(msg_vm_t vm, const char *name, void *value,void_f_pvoid_t free_ctn) {
+
+ xbt_dict_set(MSG_host_get_properties(vm), name, value,free_ctn);
+}
+
+/** @brief Immediately suspend the execution of all processes within the given VM.
+ * @ingroup msg_VMs
+ * return wheter the VM has been correctly started (0) or not (<0)
+ *
+ */
+int MSG_vm_start(msg_vm_t vm) {
+ // TODO Please complete the code
+
+ #ifdef HAVE_TRACING
+ TRACE_msg_vm_start(vm);
+ #endif
}
+
/** @brief Returns a newly constructed dynar containing all existing VMs in the system.
* @ingroup msg_VMs
*
XBT_DEBUG("Call workstation_model_init");
surf_workstation_model_description[workstation_id].model_init_preparse();
+ XBT_DEBUG("Call vm_workstation_model_init");
+ surf_vm_workstation_model_init();
+
XBT_DEBUG("Call storage_model_init");
storage_id = find_model_description(surf_storage_model_description, storage_model_name);
surf_storage_model_description[storage_id].model_init_preparse();
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(host, 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 \
return simcall_BODY_host_execution_wait(execution);
}
+
+/**
+ * \ingroup simix_vm_management
+ * \brief Returns a dict of the properties assigned to a host.
+ *
+ * \param host A host
+ * \return The properties of this host
+ */
+void* simcall_vm_create(const char *name, smx_host_t host){
+{
+ return simcall_BODY_vm_crate(name, host);
+}
+
+
/**
* \ingroup simix_process_management
* \brief Creates and runs a new SIMIX process.