Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add the {set/get}_params operations to a host object
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Mon, 11 Mar 2013 10:31:24 +0000 (11:31 +0100)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Mon, 11 Mar 2013 11:42:52 +0000 (12:42 +0100)
13 files changed:
include/msg/msg.h
include/simgrid/platf.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_host.c
src/msg/msg_vm.c
src/simix/smx_host.c
src/simix/smx_host_private.h
src/simix/smx_smurf_private.h
src/simix/smx_user.c
src/surf/vm_workstation.c
src/surf/workstation.c
src/surf/workstation_private.h

index 6584b88..b416e59 100644 (file)
@@ -113,6 +113,9 @@ XBT_PUBLIC(msg_host_t) MSG_get_host_by_name(const char *name);
 XBT_PUBLIC(xbt_dynar_t) MSG_hosts_as_dynar(void);
 XBT_PUBLIC(int) MSG_get_host_number(void);
 
+XBT_PUBLIC(void) MSG_host_get_params(msg_host_t ind_pm, ws_params_t params);
+XBT_PUBLIC(void) MSG_host_set_params(msg_host_t ind_pm, ws_params_t params);
+
 /************************** Process handling *********************************/
 XBT_PUBLIC(msg_process_t) MSG_process_create(const char *name,
                                            xbt_main_func_t code,
index 85b8505..1088975 100644 (file)
@@ -59,6 +59,11 @@ typedef enum {
 
 } e_surf_vm_state_t;
 
+typedef struct ws_params {
+  int ncpus;
+  long ramsize;
+  int overcommit;
+} s_ws_params_t, *ws_params_t;
 
 typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
 
index b7ab1d1..185bc73 100644 (file)
@@ -15,6 +15,8 @@
 #include "xbt/parmap.h"
 #include "xbt/swag.h"
 
+#include "simgrid/platf.h" // ws_params_t
+
 SG_BEGIN_DECL()
 
 /**************************** Scalar Values **********************************/
@@ -319,6 +321,8 @@ XBT_PUBLIC(double) simcall_host_execution_get_remains(smx_action_t execution);
 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_get_state(smx_action_t execution);
 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);
+XBT_PUBLIC(void) simcall_host_get_params(smx_host_t vm, ws_params_t param);
+XBT_PUBLIC(void) simcall_host_set_params(smx_host_t vm, ws_params_t param);
 
 /******************************* VM simcalls ********************************/
 // Create the vm_workstation at the SURF level
index 6e1d8f8..a0f87b6 100644 (file)
@@ -288,6 +288,9 @@ typedef struct surf_workstation_model_extension_public {
    xbt_dict_t(*get_properties) (const void *resource);
   void (*add_traces) (void);
 
+  void (*get_params) (void *ind_vm_ws, ws_params_t param);
+  void (*set_params) (void *ind_vm_ws, ws_params_t param);
+
 } s_surf_model_extension_workstation_t;
 
 typedef struct surf_vm_workstation_model_extension_public {
index 52b25ae..026eb74 100644 (file)
@@ -260,3 +260,25 @@ int MSG_host_is_avail(msg_host_t host)
   xbt_assert((host != NULL), "Invalid parameters (host is NULL)");
   return (simcall_host_get_state(host));
 }
+
+/** \ingroup m_host_management
+ * \brief Set the parameters of a given host
+ *
+ * \param host a host
+ * \param params a prameter object
+ */
+void MSG_host_set_params(msg_host_t ind_pm, ws_params_t params)
+{
+  simcall_host_set_params(ind_pm, params);
+}
+
+/** \ingroup m_host_management
+ * \brief Get the parameters of a given host
+ *
+ * \param host a host
+ * \param params a prameter object
+ */
+void MSG_host_get_params(msg_host_t ind_pm, ws_params_t params)
+{
+  simcall_host_get_params(ind_pm, params);
+}
index 77c2da7..103535a 100644 (file)
@@ -166,13 +166,17 @@ int MSG_vm_is_restoring(msg_vm_t vm)
  *
  */
 msg_vm_t MSG_vm_create(msg_host_t ind_pm, const char *name,
-                                            int core_nb, int mem_cap, int net_cap, char *disk_path, int disk_size)
+                                            int ncpus, int ramsize, int net_cap, char *disk_path, int disksize)
 {
   msg_vm_t vm = MSG_vm_create_core(ind_pm, name);
 
-  MSG_vm_set_property_value(vm, "CORE_NB", bprintf("%d", core_nb), free);
-  MSG_vm_set_property_value(vm, "MEM_CAP", bprintf("%d", mem_cap), free);
-  MSG_vm_set_property_value(vm, "NET_CAP", bprintf("%d", net_cap), free);
+  {
+    s_ws_params_t params;
+    memset(&params, 0, sizeof(params));
+    params.ramsize = ramsize;
+    params.overcommit = 0;
+    simcall_host_set_params(vm, &params);
+  }
 
   /* TODO: We will revisit the disk support later. */
 
index ef663b7..9624e63 100644 (file)
@@ -592,3 +592,33 @@ void SIMIX_set_category(smx_action_t action, const char *category)
 }
 #endif
 
+
+/**
+ * \brief Function to get the parameters of the given the SIMIX host.
+ *
+ * \param host the host to get_phys_host (a smx_host_t)
+ * \param param the parameter object space to be overwritten (a ws_params_t)
+ */
+void SIMIX_host_get_params(smx_host_t ind_vm, ws_params_t params)
+{
+  /* jump to ws_get_params(). */
+  surf_workstation_model->extension.workstation.get_params(ind_vm, params);
+}
+
+void SIMIX_pre_host_get_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params)
+{
+  SIMIX_host_get_params(ind_vm, params);
+  SIMIX_simcall_answer(simcall);
+}
+
+void SIMIX_host_set_params(smx_host_t ind_vm, ws_params_t params)
+{
+  /* jump to ws_set_params(). */
+  surf_workstation_model->extension.workstation.set_params(ind_vm, params);
+}
+
+void SIMIX_pre_host_set_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params)
+{
+  SIMIX_host_set_params(ind_vm, params);
+  SIMIX_simcall_answer(simcall);
+}
index e3f0870..b91a91e 100644 (file)
@@ -124,5 +124,11 @@ void SIMIX_pre_vm_migrate(smx_simcall_t simcall, smx_host_t ind_vm, smx_host_t i
 void *SIMIX_vm_get_pm(smx_host_t ind_vm);
 void *SIMIX_pre_vm_get_pm(smx_simcall_t simcall, smx_host_t ind_vm);
 
+void SIMIX_host_get_params(smx_host_t ind_vm, ws_params_t params);
+void SIMIX_pre_host_get_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params);
+
+void SIMIX_host_set_params(smx_host_t ind_vm, ws_params_t params);
+void SIMIX_pre_host_set_params(smx_simcall_t simcall, smx_host_t ind_vm, ws_params_t params);
+
 #endif
 
index 4137708..0a8a3bc 100644 (file)
@@ -275,6 +275,8 @@ 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_HOST_GET_PARAMS, host_get_params, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t), TSPEC(params, ws_params_t)) sep \
+ACTION(SIMCALL_HOST_SET_PARAMS, host_set_params, WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, smx_host_t), TSPEC(params, ws_params_t)) sep \
 ACTION(SIMCALL_VM_CREATE,    vm_create,    WITH_ANSWER,    TPTR(result),  TSTRING(name), TSPEC(ind_pm, smx_host_t)) sep \
 ACTION(SIMCALL_VM_START,     vm_start,     WITHOUT_ANSWER, TVOID(result), TSPEC(ind_vm, 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 \
index fecc673..3a8a71a 100644 (file)
@@ -327,6 +327,18 @@ void *simcall_vm_get_pm(smx_host_t vm)
   return simcall_BODY_vm_get_pm(vm);
 }
 
+void simcall_host_get_params(smx_host_t vm, ws_params_t params)
+{
+  /* will jump to SIMIX_pre_host_get_params in src/simix/smx_smurf_private.h */
+  simcall_BODY_host_get_params(vm, params);
+}
+
+void simcall_host_set_params(smx_host_t vm, ws_params_t params)
+{
+  /* will jump to SIMIX_pre_host_set_params in src/simix/smx_smurf_private.h */
+  simcall_BODY_host_set_params(vm, params);
+}
+
 /**
  * \ingroup simix_vm_management
  * \brief Migrate the given VM to the given physical host
index fb69640..fe7d202 100644 (file)
@@ -495,12 +495,15 @@ static void surf_vm_workstation_model_init_internal(void)
   model->extension.vm_workstation.set_state     = vm_ws_set_state;
   model->extension.vm_workstation.get_state     = vm_ws_get_state;
   model->extension.vm_workstation.migrate       = vm_ws_migrate;
-  model->extension.vm_workstation.get_pm        = vm_ws_get_pm;
   model->extension.vm_workstation.destroy       = vm_ws_destroy;
   model->extension.vm_workstation.suspend       = vm_ws_suspend;
   model->extension.vm_workstation.resume        = vm_ws_resume;
   model->extension.vm_workstation.save          = vm_ws_save;
   model->extension.vm_workstation.restore       = vm_ws_restore;
+  model->extension.vm_workstation.get_pm        = vm_ws_get_pm;
+
+  model->extension.workstation.set_params    = ws_set_params;
+  model->extension.workstation.get_params    = ws_get_params;
 
   surf_vm_workstation_model = model;
 }
index dc45d07..6003226 100644 (file)
@@ -472,6 +472,19 @@ static surf_action_t ws_action_ls(void *workstation, const char* mount, const ch
   return model->extension.storage.ls(st, path);
 }
 
+void ws_get_params(void *ws, ws_params_t params)
+{
+  workstation_CLM03_t ws_clm03 = surf_workstation_resource_priv(ws);
+  memcpy(params, &ws_clm03->params, sizeof(s_ws_params_t));
+}
+
+void ws_set_params(void *ws, ws_params_t params)
+{
+  workstation_CLM03_t ws_clm03 = surf_workstation_resource_priv(ws);
+  /* may check something here. */
+  memcpy(&ws_clm03->params, params, sizeof(s_ws_params_t));
+}
+
 static void surf_workstation_model_init_internal(void)
 {
   surf_model_t model = surf_model_init();
@@ -529,6 +542,9 @@ static void surf_workstation_model_init_internal(void)
   model->extension.workstation.unlink = ws_action_unlink;
   model->extension.workstation.ls     = ws_action_ls;
 
+  model->extension.workstation.get_params = ws_get_params;
+  model->extension.workstation.set_params = ws_set_params;
+
   surf_workstation_model = model;
 }
 
index 7c8a750..db8bd60 100644 (file)
@@ -10,6 +10,10 @@ typedef struct workstation_CLM03 {
   s_surf_resource_t generic_resource;   /* Must remain first to add this to a trace */
   void *net_elm;
   xbt_dynar_t storage;
+
+  /* common with vm */
+  s_ws_params_t params;
+
 } s_workstation_CLM03_t, *workstation_CLM03_t;
 
 int ws_action_unref(surf_action_t action);
@@ -27,4 +31,7 @@ surf_action_t ws_action_sleep(void *workstation, double duration);
 void ws_action_suspend(surf_action_t action);
 void ws_action_resume(surf_action_t action);
 e_surf_resource_state_t ws_get_state(void *workstation);
+
+void ws_get_params(void *ws, ws_params_t params);
+void ws_set_params(void *ws, ws_params_t params);
 #endif /* WS_PRIVATE_H_ */