From 8ba65b25e98c8241e28fef5266584d47bdd4c0ed Mon Sep 17 00:00:00 2001 From: Takahiro Hirofuchi Date: Mon, 11 Mar 2013 11:31:24 +0100 Subject: [PATCH] add the {set/get}_params operations to a host object --- include/msg/msg.h | 3 +++ include/simgrid/platf.h | 5 +++++ include/simgrid/simix.h | 4 ++++ src/include/surf/surf.h | 3 +++ src/msg/msg_host.c | 22 ++++++++++++++++++++++ src/msg/msg_vm.c | 12 ++++++++---- src/simix/smx_host.c | 30 ++++++++++++++++++++++++++++++ src/simix/smx_host_private.h | 6 ++++++ src/simix/smx_smurf_private.h | 2 ++ src/simix/smx_user.c | 12 ++++++++++++ src/surf/vm_workstation.c | 5 ++++- src/surf/workstation.c | 16 ++++++++++++++++ src/surf/workstation_private.h | 7 +++++++ 13 files changed, 122 insertions(+), 5 deletions(-) diff --git a/include/msg/msg.h b/include/msg/msg.h index 6584b8806c..b416e59d74 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -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, diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 85b8505a67..1088975473 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -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 */ diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index b7ab1d1794..185bc738b1 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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 diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 6e1d8f8d75..a0f87b6291 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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 { diff --git a/src/msg/msg_host.c b/src/msg/msg_host.c index 52b25ae743..026eb74239 100644 --- a/src/msg/msg_host.c +++ b/src/msg/msg_host.c @@ -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); +} diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index 77c2da7d00..103535ac8b 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -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(¶ms, 0, sizeof(params)); + params.ramsize = ramsize; + params.overcommit = 0; + simcall_host_set_params(vm, ¶ms); + } /* TODO: We will revisit the disk support later. */ diff --git a/src/simix/smx_host.c b/src/simix/smx_host.c index ef663b7cce..9624e63804 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.c @@ -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); +} diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index e3f08703ef..b91a91e55a 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -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 diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 4137708bac..0a8a3bc485 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -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 \ diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index fecc673134..3a8a71a5b9 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -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 diff --git a/src/surf/vm_workstation.c b/src/surf/vm_workstation.c index fb69640495..fe7d202e44 100644 --- a/src/surf/vm_workstation.c +++ b/src/surf/vm_workstation.c @@ -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; } diff --git a/src/surf/workstation.c b/src/surf/workstation.c index dc45d07d67..6003226215 100644 --- a/src/surf/workstation.c +++ b/src/surf/workstation.c @@ -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; } diff --git a/src/surf/workstation_private.h b/src/surf/workstation_private.h index 7c8a7500dc..db8bd60cc4 100644 --- a/src/surf/workstation_private.h +++ b/src/surf/workstation_private.h @@ -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_ */ -- 2.20.1