X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ce603fdbafff94b48f9e97700931d017c6da2c5c..069e3778afeb19b676671732f94e986d3ed73d06:/src/msg/msg_vm.cpp diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 714b70f8e7..fb1e82d780 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -12,6 +12,7 @@ #include #include "src/plugins/vm/VirtualMachineImpl.hpp" +#include "src/plugins/vm/VmHostExt.hpp" #include #include @@ -20,6 +21,8 @@ #include "xbt/log.h" #include "simgrid/host.h" +#include "src/simix/smx_host_private.h" /* don't ask me why the VM functions are in there (FIXME:KILLME) */ + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_vm, msg, "Cloud-oriented parts of the MSG API"); @@ -50,7 +53,7 @@ void MSG_vm_get_params(msg_vm_t vm, vm_params_t params) /* **** Check state of a VM **** */ static inline int __MSG_vm_is_state(msg_vm_t vm, e_surf_vm_state_t state) { - return simcall_vm_get_state(vm) == state; + return static_cast(vm)->pimpl_vm_->getState() == state; } /** @brief Returns whether the given VM has just created, not running. @@ -125,8 +128,9 @@ int MSG_vm_is_restoring(msg_vm_t vm) msg_vm_t MSG_vm_create(msg_host_t pm, const char *name, int ncpus, int ramsize, int net_cap, char *disk_path, int disksize, int mig_netspeed, int dp_intensity) { - /* For the moment, intensity_rate is the percentage against the migration - * bandwidth */ + simgrid::vm::VmHostExt::ensureVmExtInstalled(); + + /* For the moment, intensity_rate is the percentage against the migration bandwidth */ double host_speed = MSG_host_get_speed(pm); double update_speed = ((double)dp_intensity/100) * mig_netspeed; @@ -223,7 +227,8 @@ void MSG_vm_shutdown(msg_vm_t vm) { /* msg_vm_t equals to msg_host_t */ simcall_vm_shutdown(vm); - + MSG_process_sleep(0.); // Make sure that the processes in the VM are killed in this scheduling round before processing + // (eg with the VM destroy) // TRACE_msg_vm_(vm); } @@ -342,11 +347,17 @@ static int migration_rx_fun(int argc, char *argv[]) // /* Resume the VM */ // simcall_vm_resume(vm); // - simcall_vm_migratefrom_resumeto(vm, src_pm, dst_pm); + simgrid::simix::kernelImmediate([vm, src_pm, dst_pm]() { + /* Update the vm location */ + SIMIX_vm_migrate(vm, dst_pm); + + /* Resume the VM */ + SIMIX_vm_resume(vm); + }); { // Now the VM is running on the new host (the migration is completed) (even if the SRC crash) - static_cast(vm->pimpl_)->isMigrating = false; + vm->pimpl_vm_->isMigrating = false; XBT_DEBUG("VM(%s) moved from PM(%s) to PM(%s)", sg_host_get_name(ms->vm), sg_host_get_name(ms->src_pm), sg_host_get_name(ms->dst_pm)); TRACE_msg_vm_change_host(ms->vm, ms->src_pm, ms->dst_pm); @@ -395,16 +406,14 @@ static void reset_dirty_pages(msg_vm_t vm) static void start_dirty_page_tracking(msg_vm_t vm) { - simgrid::surf::VirtualMachineImpl* pimpl = static_cast(vm->pimpl_); - pimpl->dp_enabled = 1; + static_cast(vm)->pimpl_vm_->dp_enabled = 1; reset_dirty_pages(vm); } static void stop_dirty_page_tracking(msg_vm_t vm) { - simgrid::surf::VirtualMachineImpl* pimpl = static_cast(vm->pimpl_); - pimpl->dp_enabled = 0; + static_cast(vm)->pimpl_vm_->dp_enabled = 0; } static double get_computed(char *key, msg_vm_t vm, dirty_page_t dp, double remaining, double clock) @@ -420,7 +429,7 @@ static double get_computed(char *key, msg_vm_t vm, dirty_page_t dp, double remai static double lookup_computed_flop_counts(msg_vm_t vm, int stage_for_fancy_debug, int stage2_round_for_fancy_debug) { - simgrid::surf::VirtualMachineImpl* pimpl = static_cast(vm->pimpl_); + simgrid::surf::VirtualMachineImpl* pimpl = static_cast(vm)->pimpl_vm_; double total = 0; char *key = nullptr;