X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b7630a950a6b865fcc195c58e39e6c3cfa550ccb..e9f0018b823e34405847177b25a85d3facc30ae1:/src/simix/smx_vm.cpp diff --git a/src/simix/smx_vm.cpp b/src/simix/smx_vm.cpp index ae7493490a..6b32988c7d 100644 --- a/src/simix/smx_vm.cpp +++ b/src/simix/smx_vm.cpp @@ -10,6 +10,7 @@ #include "xbt/dict.h" #include "mc/mc.h" #include "src/surf/host_interface.hpp" +#include "src/surf/virtual_machine.hpp" //If you need to log some stuffs, just uncomment these two lines and uses XBT_DEBUG for instance XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_vm, simix, "Logging specific to SIMIX (vms)"); @@ -92,16 +93,19 @@ static int __can_be_started(sg_host_t vm) void SIMIX_vm_start(sg_host_t ind_vm) { if (__can_be_started(ind_vm)) - surf_host_set_state(surf_host_resource_priv(ind_vm), - (e_surf_resource_state_t) SURF_VM_STATE_RUNNING); + static_cast( + ind_vm->extension() + )->setState(SURF_VM_STATE_RUNNING); else - THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm)); + THROWF(vm_error, 0, "The VM %s cannot be started", sg_host_get_name(ind_vm)); } -int SIMIX_vm_get_state(sg_host_t ind_vm) +e_surf_vm_state_t SIMIX_vm_get_state(sg_host_t ind_vm) { - return surf_host_resource_priv(ind_vm)->getState(); + return static_cast( + ind_vm->extension() + )->getState(); } /** @@ -193,7 +197,7 @@ void SIMIX_vm_set_affinity(sg_host_t ind_vm, sg_host_t ind_pm, unsigned long mas */ void SIMIX_vm_suspend(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_RUNNING) THROWF(vm_error, 0, "VM(%s) is not running", name); @@ -233,7 +237,7 @@ void simcall_HANDLER_vm_suspend(smx_simcall_t simcall, sg_host_t ind_vm) */ void SIMIX_vm_resume(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_SUSPENDED) THROWF(vm_error, 0, "VM(%s) was not suspended", name); @@ -265,7 +269,7 @@ void simcall_HANDLER_vm_resume(smx_simcall_t simcall, sg_host_t ind_vm) */ void SIMIX_vm_save(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_RUNNING) THROWF(vm_error, 0, "VM(%s) is not running", name); @@ -297,7 +301,7 @@ void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t ind_vm) */ void SIMIX_vm_restore(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_SAVED) THROWF(vm_error, 0, "VM(%s) was not saved", name); @@ -329,7 +333,7 @@ void simcall_HANDLER_vm_restore(smx_simcall_t simcall, sg_host_t ind_vm) */ void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_RUNNING) THROWF(vm_error, 0, "VM(%s) is not running", name); @@ -344,8 +348,9 @@ void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_process_t issuer) } /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */ - surf_host_set_state(surf_host_resource_priv(ind_vm), - (e_surf_resource_state_t) SURF_VM_STATE_CREATED); + static_cast( + ind_vm->extension() + )->setState(SURF_VM_STATE_CREATED); } void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm) @@ -363,8 +368,7 @@ void SIMIX_vm_destroy(sg_host_t ind_vm) { /* this code basically performs a similar thing like SIMIX_host_destroy() */ - xbt_assert((ind_vm != NULL), "Invalid parameters"); - const char *hostname = SIMIX_host_get_name(ind_vm); + const char *hostname = sg_host_get_name(ind_vm); XBT_DEBUG("destroy %s", hostname);