X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9ba3bfdef0f13d77474c16059ca813b75ade43ab..5c979a2a19b47295bc467cfda3c6541f60b6fe13:/src/surf/virtual_machine.cpp diff --git a/src/surf/virtual_machine.cpp b/src/surf/virtual_machine.cpp index 37b24e7400..cc11586da1 100644 --- a/src/surf/virtual_machine.cpp +++ b/src/surf/virtual_machine.cpp @@ -33,9 +33,9 @@ VMModel::vm_list_t VMModel::ws_vms; * Resource * ************/ -VirtualMachine::VirtualMachine(Model *model, const char *name, xbt_dict_t props, - RoutingEdge *netElm, Cpu *cpu) -: Host(model, name, props, NULL, netElm, cpu) +VirtualMachine::VirtualMachine(Model *model, const char *name, xbt_dict_t props, simgrid::Host *hostPM) +: Host(model, name, props, NULL, NULL, NULL) +, p_hostPM(hostPM) { VMModel::ws_vms.push_back(*this); simgrid::Host::by_name_or_create(name)->extension_set(this); @@ -49,27 +49,35 @@ VirtualMachine::~VirtualMachine() { VMDestructedCallbacks(this); VMModel::ws_vms.erase(VMModel::vm_list_t::s_iterator_to(*this)); + /* Free the cpu_action of the VM. */ + XBT_ATTRIB_UNUSED int ret = p_action->unref(); + xbt_assert(ret == 1, "Bug: some resource still remains"); } -void VirtualMachine::setState(e_surf_resource_state_t state){ - Resource::setState(state); - VMStateChangedCallbacks(this); +e_surf_vm_state_t VirtualMachine::getState() { + return p_vm_state; } -/* - * A surf level object will be useless in the upper layer. Returning the - * dict_elm of the host. - **/ -sg_host_t VirtualMachine::getPm() -{ - return p_subWs->getHost(); +void VirtualMachine::setState(e_surf_vm_state_t state) { + p_vm_state = state; +} +void VirtualMachine::turnOn() { + if (isOff()) { + Resource::turnOn(); + VMStateChangedCallbacks(this); + } +} +void VirtualMachine::turnOff() { + if (isOn()) { + Resource::turnOff(); + VMStateChangedCallbacks(this); + } } -/********** - * Action * - **********/ - -//FIME:: handle action cancel +/** @brief returns the physical machine on which the VM is running **/ +sg_host_t VirtualMachine::getPm() { + return p_hostPM; +} } }