1 /* Copyright (c) 2013-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "cpu_cas01.hpp"
8 #include "virtual_machine.hpp"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf,
11 "Logging specific to the SURF VM module");
13 simgrid::surf::VMModel *surf_vm_model = NULL;
22 simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMCreatedCallbacks;
23 simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMDestructedCallbacks;
24 simgrid::surf::signal<void(simgrid::surf::VirtualMachine*)> VMStateChangedCallbacks;
30 VMModel::vm_list_t VMModel::ws_vms;
36 VirtualMachine::VirtualMachine(Model *model, const char *name, xbt_dict_t props,simgrid::Host *hostPM)
37 : Host(model, name, props, NULL, NULL, NULL)
40 VMModel::ws_vms.push_back(*this);
41 simgrid::Host::by_name_or_create(name)->extension_set<simgrid::surf::Host>(this);
45 * A physical host does not disappear in the current SimGrid code, but a VM may
46 * disappear during a simulation.
48 VirtualMachine::~VirtualMachine()
50 VMDestructedCallbacks(this);
51 VMModel::ws_vms.erase(VMModel::vm_list_t::s_iterator_to(*this));
54 void VirtualMachine::setState(e_surf_resource_state_t state){
55 Resource::setState(state);
56 VMStateChangedCallbacks(this);
59 /** @brief returns the physical machine on which the VM is running **/
60 sg_host_t VirtualMachine::getPm() {