Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright notices
[simgrid.git] / src / surf / vm_interface.cpp
1 /* Copyright (c) 2013-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "cpu_cas01.hpp"
8 #include "vm_interface.hpp"
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf,
11                                 "Logging specific to the SURF VM module");
12
13 VMModel *surf_vm_model = NULL;
14
15 /*************
16  * Callbacks *
17  *************/
18
19 surf_callback(void, VM*) VMCreatedCallbacks;
20 surf_callback(void, VM*) VMDestructedCallbacks;
21 surf_callback(void, VM*) VMStateChangedCallbacks;
22
23 /*********
24  * Model *
25  *********/
26
27 VMModel::vm_list_t VMModel::ws_vms;
28
29 /************
30  * Resource *
31  ************/
32
33 VM::VM(Model *model, const char *name, xbt_dict_t props,
34                         RoutingEdge *netElm, Cpu *cpu)
35 : Host(model, name, props, NULL, netElm, cpu)
36 {
37   VMModel::ws_vms.push_back(*this);
38   surf_callback_emit(VMCreatedCallbacks, this);
39 }
40
41 /*
42  * A physical host does not disappear in the current SimGrid code, but a VM may
43  * disappear during a simulation.
44  */
45 VM::~VM()
46 {
47   surf_callback_emit(VMDestructedCallbacks, this);
48   VMModel::ws_vms.erase(VMModel::vm_list_t::s_iterator_to(*this));
49 }
50
51 void VM::setState(e_surf_resource_state_t state){
52   Resource::setState(state);
53   surf_callback_emit(VMStateChangedCallbacks, this);
54 }
55
56 /*
57  * A surf level object will be useless in the upper layer. Returning the
58  * dict_elm of the host.
59  **/
60 surf_resource_t VM::getPm()
61 {
62   return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
63 }
64
65 /**********
66  * Action *
67  **********/
68
69 //FIME:: handle action cancel
70