Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix cpu issues with VMs
[simgrid.git] / src / surf / vm_workstation_interface.cpp
1 /*
2  * vm_workstation.cpp
3  *
4  *  Created on: Nov 12, 2013
5  *      Author: bedaride
6  */
7 #include "vm_workstation_interface.hpp"
8 #include "cpu_cas01.hpp"
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm_workstation, surf,
11                                 "Logging specific to the SURF VM workstation module");
12
13 WorkstationVMModelPtr surf_vm_workstation_model = NULL;
14
15 /*************
16  * Callbacks *
17  *************/
18
19 surf_callback(void, WorkstationVMPtr) workstationVMCreatedCallbacks;
20 surf_callback(void, WorkstationVMPtr) workstationVMDestructedCallbacks;
21 surf_callback(void, WorkstationVMPtr) workstationVMStateChangedCallbacks;
22
23 /*********
24  * Model *
25  *********/
26
27 WorkstationVMModel::WorkstationVMModel() : WorkstationModel("Virtual Workstation") {
28   p_cpuModel = surf_cpu_model_vm;
29 }
30
31 /************
32  * Resource *
33  ************/
34
35 WorkstationVM::WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
36                         RoutingEdgePtr netElm, CpuPtr cpu)
37 : Workstation(model, name, props, NULL, netElm, cpu)
38 {
39   surf_callback_emit(workstationVMCreatedCallbacks, this);
40 }
41
42 /*
43  * A physical host does not disapper in the current SimGrid code, but a VM may
44  * disapper during a simulation.
45  */
46 WorkstationVM::~WorkstationVM()
47 {
48   surf_callback_emit(workstationVMDestructedCallbacks, this);
49 }
50
51 void WorkstationVM::setState(e_surf_resource_state_t state){
52   Resource::setState(state);
53   surf_callback_emit(workstationVMStateChangedCallbacks, this);
54 }
55
56 /*
57  * A surf level object will be useless in the upper layer. Returing the
58  * dict_elm of the host.
59  **/
60 surf_resource_t WorkstationVM::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