X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/783b33766eccfc78e3b205d896323169ec42e7c1..4eb7bc51e832299d593ccb590b54a2ac3a9590d6:/src/simix/smx_vm.cpp diff --git a/src/simix/smx_vm.cpp b/src/simix/smx_vm.cpp index ba05d17e6a..2866b91b4b 100644 --- a/src/simix/smx_vm.cpp +++ b/src/simix/smx_vm.cpp @@ -3,39 +3,19 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "smx_private.h" #include "mc/mc.h" -#include "src/surf/virtual_machine.hpp" +#include "simgrid/s4u/VirtualMachine.hpp" +#include "smx_private.h" +#include "src/plugins/vm/VirtualMachineImpl.hpp" #include "src/surf/HostImpl.hpp" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX (vms)"); - -/* **** create a VM **** */ - -/** - * @brief Internal function to create a SIMIX host. - * @param name name of the host to create - * @param data some user data (may be nullptr) - */ -sg_host_t SIMIX_vm_create(const char *name, sg_host_t ind_phys_host) -{ - /* Create surf associated resource */ - surf_vm_model_create(name, ind_phys_host); - sg_host_t host = sg_host_by_name(name); - SIMIX_host_create(host); - - /* We will be able to register the VM to its physical host, so that we can promptly - * retrieve the list VMs on the physical host. */ - - return host; -} - +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX Virtual Machines"); /* works for VMs and PMs */ static long host_get_ramsize(sg_host_t vm, int *overcommit) { s_vm_params_t params; - vm->extension()->getParams(¶ms); + static_cast(vm)->parameters(¶ms); if (overcommit) *overcommit = params.overcommit; @@ -63,7 +43,7 @@ static int __can_be_started(sg_host_t vm) } long total_ramsize_of_vms = 0; - xbt_dynar_t dyn_vms = pm->extension()->getVms(); + xbt_dynar_t dyn_vms = pm->pimpl_->getVms(); { unsigned int cursor = 0; sg_host_t another_vm; @@ -84,22 +64,18 @@ static int __can_be_started(sg_host_t vm) return 1; } -void SIMIX_vm_start(sg_host_t ind_vm) +void SIMIX_vm_start(sg_host_t vm) { - if (__can_be_started(ind_vm)) - static_cast( - ind_vm->extension() - )->setState(SURF_VM_STATE_RUNNING); + if (__can_be_started(vm)) + static_cast(vm->pimpl_)->setState(SURF_VM_STATE_RUNNING); else - THROWF(vm_error, 0, "The VM %s cannot be started", sg_host_get_name(ind_vm)); + THROWF(vm_error, 0, "The VM %s cannot be started", vm->name().c_str()); } -e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t ind_vm) +e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t vm) { - return static_cast( - ind_vm->extension() - )->getState(); + return static_cast(vm->pimpl_)->getState(); } /** @@ -107,13 +83,13 @@ e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t ind_vm) * * @param host the vm host to migrate (a sg_host_t) */ -void SIMIX_vm_migrate(sg_host_t ind_vm, sg_host_t ind_dst_pm) +void SIMIX_vm_migrate(sg_host_t vm, sg_host_t dst_pm) { /* precopy migration makes the VM temporally paused */ - xbt_assert(SIMIX_vm_get_state(ind_vm) == SURF_VM_STATE_SUSPENDED); + xbt_assert(SIMIX_vm_get_state(vm) == SURF_VM_STATE_SUSPENDED); /* jump to vm_ws_xigrate(). this will update the vm location. */ - surf_vm_migrate(ind_vm, ind_dst_pm); + surf_vm_migrate(vm, dst_pm); } /** @@ -135,7 +111,7 @@ void SIMIX_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t dst /* Resume the VM */ smx_actor_t self = SIMIX_process_self(); - SIMIX_vm_resume(vm, self->simcall.issuer); + SIMIX_vm_resume(vm, self); } /** @@ -309,9 +285,7 @@ void SIMIX_vm_shutdown(sg_host_t vm, smx_actor_t issuer) } /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */ - static_cast( - vm->extension() - )->setState(SURF_VM_STATE_CREATED); + static_cast(vm->pimpl_)->setState(SURF_VM_STATE_CREATED); } void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t vm) @@ -340,4 +314,6 @@ void SIMIX_vm_destroy(sg_host_t vm) /* Don't free these things twice: they are the ones of my physical host */ vm->pimpl_cpu = nullptr; vm->pimpl_netcard = nullptr; + + vm->destroy(); }