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 VMModel *surf_vm_model = NULL;
19 surf_callback(void, VirtualMachine*) VMCreatedCallbacks;
20 surf_callback(void, VirtualMachine*) VMDestructedCallbacks;
21 surf_callback(void, VirtualMachine*) VMStateChangedCallbacks;
27 VMModel::vm_list_t VMModel::ws_vms;
33 VirtualMachine::VirtualMachine(Model *model, const char *name, xbt_dict_t props,
34 RoutingEdge *netElm, Cpu *cpu)
35 : Host(model, name, props, NULL, netElm, cpu)
37 VMModel::ws_vms.push_back(*this);
39 xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, this);
43 * A physical host does not disappear in the current SimGrid code, but a VM may
44 * disappear during a simulation.
46 VirtualMachine::~VirtualMachine()
48 surf_callback_emit(VMDestructedCallbacks, this);
49 VMModel::ws_vms.erase(VMModel::vm_list_t::s_iterator_to(*this));
52 void VirtualMachine::setState(e_surf_resource_state_t state){
53 Resource::setState(state);
54 surf_callback_emit(VMStateChangedCallbacks, this);
58 * A surf level object will be useless in the upper layer. Returning the
59 * dict_elm of the host.
61 surf_resource_t VirtualMachine::getPm()
63 return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
70 //FIME:: handle action cancel