From 231fedb1f0211c7c11f91e284a97485ac3bc6649 Mon Sep 17 00:00:00 2001 From: Takahiro Hirofuchi Date: Mon, 4 Feb 2013 14:32:29 +0100 Subject: [PATCH] make the prefix of the functions consistent, e.g., vm_{get/set}_state --- include/simgrid/simix.h | 7 +++++-- src/msg/instr_msg_vm.c | 2 +- src/msg/msg_vm.c | 4 ++-- src/simix/smx_host_private.h | 6 +++--- src/simix/smx_smurf_private.h | 2 +- src/simix/smx_user.c | 13 ++++++++++--- src/simix/smx_vm.c | 28 ++++++++++++++-------------- 7 files changed, 36 insertions(+), 26 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 7e678c6b24..fca2ef25a6 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -330,11 +330,14 @@ 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_create(const char *name, smx_host_t host); +XBT_PUBLIC(int) simcall_vm_get_state(smx_host_t vm); XBT_PUBLIC(void) simcall_vm_start(smx_host_t vm); +XBT_PUBLIC(void) simcall_vm_migrate(smx_host_t vm, smx_host_t dst_pm); +XBT_PUBLIC(const char*) simcall_vm_get_phys_host(smx_host_t vm); XBT_PUBLIC(void) simcall_vm_suspend(smx_host_t vm); XBT_PUBLIC(void) simcall_vm_destroy(smx_host_t vm); +XBT_PUBLIC(void) simcall_vm_shutdown(smx_host_t vm); /**************************** Process simcalls ********************************/ /* Constructor and Destructor */ diff --git a/src/msg/instr_msg_vm.c b/src/msg/instr_msg_vm.c index 770f4cf9c9..cc91b32c6c 100644 --- a/src/msg/instr_msg_vm.c +++ b/src/msg/instr_msg_vm.c @@ -13,7 +13,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_vm, instr, "MSG VM"); char *instr_vm_id (msg_vm_t vm, char *str, int len) { - return instr_vm_id_2 (MSG_get_vm_name(vm), str, len); + return instr_vm_id_2 (MSG_vm_get_name(vm), str, len); } char *instr_vm_id_2 (const char *vm_name, char *str, int len) diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index 2b188373ad..b6f55c743e 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -107,7 +107,7 @@ msg_vm_t MSG_vm_create(msg_host_t ind_host, const char *name, msg_vm_t new = NULL; void *ind_vm_workstation = NULL; // Ask simix to create the surf vm resource - ind_vm_workstation = simcall_vm_ws_create(name,ind_host); + ind_vm_workstation = simcall_vm_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); @@ -142,7 +142,7 @@ void MSG_vm_start(msg_vm_t vm) { /* **** Check state of a VM **** */ int __MSG_vm_is_state(msg_vm_t vm, e_msg_vm_state_t state) { - return simcall_get_vm_state(vm) == state ; + return simcall_vm_get_state(vm) == state ; } /** @brief Returns whether the given VM is currently suspended diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index d586ea6a99..7edebe0c1a 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -94,10 +94,10 @@ smx_host_t SIMIX_pre_vm_create(smx_simcall_t simcall, const char *name, smx_host void SIMIX_vm_start(smx_host_t ind_vm); void SIMIX_pre_vm_start(smx_simcall_t simcall, smx_host_t ind_vm); -void SIMIX_set_vm_state(smx_host_t ind_vm, int state); -void SIMIX_prev_set_vm_state(smx_host_t ind_vm, int state); +void SIMIX_vm_set_state(smx_host_t ind_vm, int state); +void SIMIX_prev_vm_set_state(smx_host_t ind_vm, int state); -int SIMIX_get_vm_state(smx_host_t ind_vm); +int SIMIX_vm_get_state(smx_host_t ind_vm); int SIMIX_pre_vm_state(smx_host_t ind_vm); void SIMIX_vm_suspend(smx_host_t ind_vm); diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 4d63029d45..18d0accc20 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -274,7 +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_WS_CREATE, vm_ws_create, WITH_ANSWER, TPTR(result), TSTRING(name), TSPEC(phys_host, smx_host_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(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 \ diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 016f7abd8a..95e6b844a4 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -282,12 +282,19 @@ e_smx_state_t simcall_host_execution_wait(smx_action_t execution) * \param host A host * \return The properties of this 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_create(const char *name, smx_host_t phys_host){ + /* jump to SIMIX_pre_vm_create() */ + return simcall_BODY_vm_create(name, phys_host); } void simcall_vm_start(smx_host_t vm) { - simcall_BODY_set_vm_state(vm, msg_vm_state_running); + simcall_BODY_vm_set_state(vm, msg_vm_state_running); +} + +int simcall_vm_get_state(smx_host_t vm) +{ + /* will jump to SIMIX_pre_vm_get_state */ + return simcall_BODY_vm_get_state(vm); } void simcall_vm_migrate(smx_host_t vm, smx_host_t dst_phys) diff --git a/src/simix/smx_vm.c b/src/simix/smx_vm.c index cd1a29a6ba..dd3c42d9fc 100644 --- a/src/simix/smx_vm.c +++ b/src/simix/smx_vm.c @@ -50,15 +50,15 @@ smx_host_t SIMIX_pre_vm_create(smx_simcall_t simcall, const char *name, smx_host /* **** start a VM **** */ -int __can_be_started(smx_host_t vm){ +static int __can_be_started(smx_host_t vm){ // TODO add checking code related to overcommitment or not. return 1; } void SIMIX_vm_start(smx_host_t ind_vm){ //TODO only start the VM if you can - if (can_be_started(ind_vm)) - SIMIX_set_vm_state(ind_vm, msg_vm_state_running); + if (__can_be_started(ind_vm)) + SIMIX_vm_set_state(ind_vm, msg_vm_state_running); else THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm)); } @@ -68,18 +68,18 @@ void SIMIX_pre_vm_start(smx_simcall_t simcall, smx_host_t ind_vm){ } /* ***** set/get state of a VM ***** */ -void SIMIX_set_vm_state(smx_host_t ind_vm, int state){ +void SIMIX_vm_set_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 ind_vm, int state){ - SIMIX_set_vm_state(ind_vm, state); +void SIMIX_pre_vm_set_state(smx_host_t ind_vm, int state){ + SIMIX_vm_set_state(ind_vm, state); } -int SIMIX_get_vm_state(smx_host_t ind_vm){ +int SIMIX_vm_get_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 ind_vm){ - return SIMIX_get_vm_state(ind_vm); +int SIMIX_pre_vm_get_state(smx_host_t ind_vm){ + return SIMIX_vm_get_state(ind_vm); } /** @@ -94,12 +94,12 @@ void SIMIX_vm_migrate(smx_host_t ind_vm, smx_host_t ind_dst_pm) /* TODO: check state */ /* TODO: Using the variable of the MSG layer is not clean. */ - SIMIX_set_vm_state(ind_vm, msg_vm_state_migrating); + SIMIX_vm_set_state(ind_vm, msg_vm_state_migrating); /* jump to vm_ws_migrate(). this will update the vm location. */ surf_vm_workstation_model->extension.vm_workstation.migrate(ind_vm, ind_dst_pm); - SIMIX_set_vm_state(ind_vm, msg_vm_state_running); + SIMIX_vm_set_state(ind_vm, msg_vm_state_running); } void SIMIX_pre_vm_migrate(smx_simcall_t simcall, smx_host_t ind_vm, smx_host_t ind_dst_pm){ @@ -142,7 +142,7 @@ void SIMIX_vm_suspend(smx_host_t ind_vm) } /* TODO: Using the variable of the MSG layer is not clean. */ - SIMIX_set_vm_state(ind_vm, msg_vm_state_suspended); + SIMIX_vm_set_state(ind_vm, msg_vm_state_suspended); } void SIMIX_pre_vm_suspend(smx_simcall_t simcall, smx_host_t ind_vm){ @@ -169,7 +169,7 @@ void SIMIX_vm_resume(smx_host_t ind_vm) } /* TODO: Using the variable of the MSG layer is not clean. */ - SIMIX_set_vm_state(ind_vm, msg_vm_state_running); + SIMIX_vm_set_state(ind_vm, msg_vm_state_running); } void SIMIX_pre_vm_resume(smx_simcall_t simcall, smx_host_t ind_vm){ @@ -197,7 +197,7 @@ void SIMIX_vm_shutdown(smx_host_t ind_vm, smx_process_t issuer) } /* TODO: Using the variable of the MSG layer is not clean. */ - SIMIX_set_vm_state(ind_vm, msg_vm_state_sleeping); + SIMIX_vm_set_state(ind_vm, msg_vm_state_sleeping); } void SIMIX_pre_vm_shutdown(smx_simcall_t simcall, smx_host_t ind_vm){ -- 2.20.1