Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
First complete implementation of a new MSG call (starting from MSG down
authoralebre <adrien.lebre@inria.fr>
Thu, 31 Jan 2013 08:25:47 +0000 (09:25 +0100)
committeralebre <adrien.lebre@inria.fr>
Thu, 31 Jan 2013 08:32:13 +0000 (09:32 +0100)
to surf)

include/msg/datatypes.h
include/msg/msg.h
src/include/surf/surf.h
src/msg/msg_host.c
src/msg/msg_vm.c
src/simgrid/sg_config.c
src/simix/smx_smurf_private.h
src/simix/smx_user.c

index 0536dbb..9394bf1 100644 (file)
@@ -46,7 +46,10 @@ typedef xbt_dictelm_t msg_host_t;
 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
@@ -81,22 +84,40 @@ typedef struct msg_task {
  */
 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;
index 5f0077e..6666ff7 100644 (file)
@@ -338,7 +338,12 @@ XBT_PUBLIC(int) MSG_get_channel_number(void);
  *
  */
 /* 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);
index 5a612ac..36c30c8 100644 (file)
@@ -276,8 +276,10 @@ typedef struct surf_workstation_model_extension_public {
 
 } 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
@@ -323,6 +325,8 @@ typedef struct surf_model {
     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;
index a767553..8098e23 100644 (file)
@@ -30,9 +30,8 @@ msg_host_t __MSG_host_create(smx_host_t workstation)
 {
   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;
index c025372..66e1bc7 100644 (file)
@@ -17,26 +17,78 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_vm, msg,
  *  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
  *
index 3d853d4..1b8a6a6 100644 (file)
@@ -785,6 +785,9 @@ void surf_config_models_setup()
   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();
index a418dd0..f08a07b 100644 (file)
@@ -274,6 +274,7 @@ ACTION(SIMCALL_HOST_EXECUTION_GET_REMAINS, host_execution_get_remains, WITH_ANSW
 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 \
index 15fca99..0a92bb8 100644 (file)
@@ -274,6 +274,20 @@ e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
   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.