From 7d87977bedfedbb1d84d0805e6ef5964983e864a Mon Sep 17 00:00:00 2001 From: Adrien Lebre Date: Wed, 13 May 2015 13:56:18 +0200 Subject: [PATCH] First steps to add a new VM simcall - Ad(rien) --- src/simix/libsmx.c | 22 ++++++++++++++++++++++ src/simix/popping_accessors.h | 19 +++++++++++++++++++ src/simix/popping_bodies.c | 23 +++++++++++++++++++++++ src/simix/popping_generated.c | 6 ++++++ src/simix/simcalls.in | 8 ++++++-- 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/simix/libsmx.c b/src/simix/libsmx.c index 35b3c8ec62..b3c48f3158 100644 --- a/src/simix/libsmx.c +++ b/src/simix/libsmx.c @@ -532,6 +532,28 @@ void simcall_vm_destroy(smx_host_t vm) simcall_BODY_vm_destroy(vm); } +Proc - vm_migratefrom_resumeto (void) (ind_vm, void*, smx_host_t)(ind_src_pm, void*, smx_host_t) (ind_dst_pm, void*, smx_host_t) +/** + * \ingroup simix_vm_management + * \brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration + * The simcall actually invokes the following calls: + * simcall_vm_set_affinity(vm, src_pm, 0); + * simcall_vm_migrate(vm, dst_pm); + * simcall_vm_resume(vm); + * + * It is called at the end of the migration_rx_fun function from msg/msg_vm.c + * + * \param vm VM to migrate + * \param src_pm Source physical host + * \param dst_pmt Destination physical host + + */ +void simcall_vm_migratefrom_resumeto(smx_host_t vm, smx_host_t src_pm, smx_host_t dst_pm) +{ + simcall_BODY_vm_migratefrom_resumeto(vm, src_pm, dst_pm); +} + + /** * \ingroup simix_process_management diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index be8bd6650f..b307993b00 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -584,6 +584,25 @@ static inline void simcall_vm_restore__set__ind_vm(smx_simcall_t simcall, void* simcall->args[0].dp = arg; } +static inline smx_host_t simcall_vm_migratefrom_resumeto__get__ind_vm(smx_simcall_t simcall) { + return (smx_host_t) simcall->args[0].dp; +} +static inline void simcall_vm_migratefrom_resumeto__set__ind_vm(smx_simcall_t simcall, void* arg) { + simcall->args[0].dp = arg; +} +static inline smx_host_t simcall_vm_migratefrom_resumeto__get__ind_src_pm(smx_simcall_t simcall) { + return (smx_host_t) simcall->args[1].dp; +} +static inline void simcall_vm_migratefrom_resumeto__set__ind_src_pm(smx_simcall_t simcall, void* arg) { + simcall->args[1].dp = arg; +} +static inline smx_host_t simcall_vm_migratefrom_resumeto__get__ind_dst_pm(smx_simcall_t simcall) { + return (smx_host_t) simcall->args[2].dp; +} +static inline void simcall_vm_migratefrom_resumeto__set__ind_dst_pm(smx_simcall_t simcall, void* arg) { + simcall->args[2].dp = arg; +} + static inline smx_process_t* simcall_process_create__get__process(smx_simcall_t simcall) { return (smx_process_t*) simcall->args[0].dp; } diff --git a/src/simix/popping_bodies.c b/src/simix/popping_bodies.c index 0b413a2c7b..e538690a8f 100644 --- a/src/simix/popping_bodies.c +++ b/src/simix/popping_bodies.c @@ -923,6 +923,29 @@ inline static void simcall_BODY_vm_restore(smx_host_t ind_vm) { } +inline static void simcall_BODY_vm_migratefrom_resumeto(smx_host_t ind_vm, smx_host_t ind_src_pm, smx_host_t ind_dst_pm) { + smx_process_t self = SIMIX_process_self(); + + /* Go to that function to follow the code flow through the simcall barrier */ + if (0) SIMIX_vm_migratefrom_resumeto(ind_vm, ind_src_pm, ind_dst_pm); + /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ + + self->simcall.call = SIMCALL_VM_MIGRATEFROM_RESUMETO; + memset(&self->simcall.result, 0, sizeof(self->simcall.result)); + memset(self->simcall.args, 0, sizeof(self->simcall.args)); + self->simcall.args[0].dp = (void*) ind_vm; + self->simcall.args[1].dp = (void*) ind_src_pm; + self->simcall.args[2].dp = (void*) ind_dst_pm; + if (self != simix_global->maestro_process) { + XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, + SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); + SIMIX_process_yield(self); + } else { + SIMIX_simcall_handle(&self->simcall, 0); + } + + } + inline static void simcall_BODY_process_create(smx_process_t* process, const char* name, xbt_main_func_t code, void* data, const char* hostname, double kill_time, int argc, char** argv, xbt_dict_t properties, int auto_restart) { smx_process_t self = SIMIX_process_self(); diff --git a/src/simix/popping_generated.c b/src/simix/popping_generated.c index fb72a40b29..46e54ef6f6 100644 --- a/src/simix/popping_generated.c +++ b/src/simix/popping_generated.c @@ -63,6 +63,7 @@ const char* simcall_names[] = { [SIMCALL_VM_SHUTDOWN] = "SIMCALL_VM_SHUTDOWN", [SIMCALL_VM_SAVE] = "SIMCALL_VM_SAVE", [SIMCALL_VM_RESTORE] = "SIMCALL_VM_RESTORE", + [SIMCALL_VM_MIGRATEFROM_RESUMETO] = "SIMCALL_VM_MIGRATEFROM_RESUMETO", [SIMCALL_PROCESS_CREATE] = "SIMCALL_PROCESS_CREATE", [SIMCALL_PROCESS_KILL] = "SIMCALL_PROCESS_KILL", [SIMCALL_PROCESS_KILLALL] = "SIMCALL_PROCESS_KILLALL", @@ -372,6 +373,11 @@ case SIMCALL_VM_RESTORE: SIMIX_simcall_answer(simcall); break; +case SIMCALL_VM_MIGRATEFROM_RESUMETO: + SIMIX_vm_migratefrom_resumeto((smx_host_t) simcall->args[0].dp,(smx_host_t) simcall->args[1].dp,(smx_host_t) simcall->args[2].dp); + SIMIX_simcall_answer(simcall); + break; + case SIMCALL_PROCESS_CREATE: simcall_HANDLER_process_create(simcall , (smx_process_t*) simcall->args[0].dp, simcall->args[1].cc, (xbt_main_func_t) simcall->args[2].fp, simcall->args[3].dp, simcall->args[4].cc, simcall->args[5].d, simcall->args[6].i, (char**) simcall->args[7].dp, (xbt_dict_t) simcall->args[8].dp, simcall->args[9].i); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 154c162cbd..e8faeb107d 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -26,8 +26,6 @@ # a surf simulation round. Weird things happen if you forget to # answer a given simcall in there... - - # Handler? is either "H" if we need to generate a handler or "-" if we should go without handlers # I wish we could completely remove the handlers as their only use is @@ -38,6 +36,11 @@ # identity as a parameter of internal call, but that could be # automatized too (eg by having a special parameter type called "self") +# Please note that in addition to completing this file with your new simcall, +# you should complete the libsmx.c file by adding the corresponding function +# (aka. stub). Anyway, if you omit to do it, the invocation of ./simcalls.py will notify you ;) + + Func - host_get_by_name (void*, smx_host_t) (name, const char*) Func - host_get_name (const char*) (host, void*, smx_host_t) Proc - host_on (void) (host, void*, smx_host_t) @@ -81,6 +84,7 @@ Proc H vm_resume (void) (ind_vm, void*, smx_host_t) Proc H vm_shutdown (void) (ind_vm, void*, smx_host_t) Proc H vm_save (void) (ind_vm, void*, smx_host_t) Proc H vm_restore (void) (ind_vm, void*, smx_host_t) +Proc - vm_migratefrom_resumeto (void) (ind_vm, void*, smx_host_t)(ind_src_pm, void*, smx_host_t) (ind_dst_pm, void*, smx_host_t) Proc H process_create (void) (process, void*, smx_process_t*) (name, const char*) (code, FPtr, xbt_main_func_t) (data, void*) (hostname, const char*) (kill_time, double) (argc, int) (argv, void*, char**) (properties, void*, xbt_dict_t) (auto_restart, int) Proc H process_kill (void) (process, void*, smx_process_t) Proc H process_killall (void) (reset_pid, int) -- 2.20.1