1 /* Copyright (c) 2013-2014. 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 "vm_interface.hpp"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf,
11 "Logging specific to the SURF VM module");
13 VMModelPtr surf_vm_model = NULL;
19 surf_callback(void, VMPtr) VMCreatedCallbacks;
20 surf_callback(void, VMPtr) VMDestructedCallbacks;
21 surf_callback(void, VMPtr) VMStateChangedCallbacks;
27 VMModel::VMModel() : HostModel("Virtual Machine") {
28 p_cpuModel = surf_cpu_model_vm;
31 VMModel::vm_list_t VMModel::ws_vms;
37 VM::VM(ModelPtr model, const char *name, xbt_dict_t props,
38 RoutingEdgePtr netElm, CpuPtr cpu)
39 : Host(model, name, props, NULL, netElm, cpu)
41 VMModel::ws_vms.push_back(*this);
42 surf_callback_emit(VMCreatedCallbacks, this);
46 * A physical host does not disapper in the current SimGrid code, but a VM may
47 * disapper during a simulation.
51 surf_callback_emit(VMDestructedCallbacks, this);
52 VMModel::ws_vms.erase(VMModel::
53 vm_list_t::s_iterator_to(*this));
56 void VM::setState(e_surf_resource_state_t state){
57 Resource::setState(state);
58 surf_callback_emit(VMStateChangedCallbacks, this);
62 * A surf level object will be useless in the upper layer. Returing the
63 * dict_elm of the host.
65 surf_resource_t VM::getPm()
67 return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
74 //FIME:: handle action cancel