Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / surf / vm_workstation_interface.hpp
1 /* Copyright (c) 2004-2014. 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 "workstation_interface.hpp"
8
9 #ifndef VM_WORKSTATION_INTERFACE_HPP_
10 #define VM_WORKSTATION_INTERFACE_HPP_
11
12 #define GUESTOS_NOISE 100 // This value corresponds to the cost of the global action associated to the VM
13                           // It corresponds to the cost of a VM running no tasks.
14
15 void surf_vm_workstation_model_init(void);
16
17 /***********
18  * Classes *
19  ***********/
20
21 class WorkstationVMModel;
22 typedef WorkstationVMModel *WorkstationVMModelPtr;
23
24 class WorkstationVM;
25 typedef WorkstationVM *WorkstationVMPtr;
26
27 class WorkstationVMLmm;
28 typedef WorkstationVMLmm *WorkstationVMLmmPtr;
29
30 /*************
31  * Callbacks *
32  *************/
33
34 /** @ingroup SURF_callbacks
35  * @brief Callbacks handler which emit the callbacks after WorkstationVM creation *
36  * @details Callback functions have the following signature: `void(WorkstationVMPtr)`
37  */
38 extern surf_callback(void, WorkstationVMPtr) workstationVMCreatedCallbacks;
39
40 /** @ingroup SURF_callbacks
41  * @brief Callbacks handler which emit the callbacks after WorkstationVM destruction *
42  * @details Callback functions have the following signature: `void(WorkstationVMPtr)`
43  */
44 extern surf_callback(void, WorkstationVMPtr) workstationVMDestructedCallbacks;
45
46 /** @ingroup SURF_callbacks
47  * @brief Callbacks handler which emit the callbacks after WorkstationVM State changed *
48  * @details Callback functions have the following signature: `void(WorkstationVMActionPtr)`
49  */
50 extern surf_callback(void, WorkstationVMPtr) workstationVMStateChangedCallbacks;
51
52 /*********
53  * Model *
54  *********/
55 /** @ingroup SURF_vm_workstation_interface
56  * @brief SURF workstation VM model interface class
57  * @details A model is an object which handle the interactions between its Resources and its Actions
58  */
59 class WorkstationVMModel : public WorkstationModel {
60 public:
61   /**
62    * @brief WorkstationVMModel consrtuctor
63    */
64   WorkstationVMModel();
65
66     /**
67    * @brief WorkstationVMModel consrtuctor
68    */
69   ~WorkstationVMModel(){};
70
71   /**
72    * @brief Create a new WorkstationVM
73    * 
74    * @param name The name of the new WorkstationVM
75    * @param ind_phys_workstation The workstation hosting the VM
76    * 
77    */
78   virtual void createResource(const char *name, void *ind_phys_workstation)=0;
79
80   void adjustWeightOfDummyCpuActions() {};
81 };
82
83 /************
84  * Resource *
85  ************/
86
87 /** @ingroup SURF_vm_workstation_interface
88  * @brief SURF workstation VM interface class
89  * @details A workstation VM represent an virtual machine
90  */
91 class WorkstationVM : public Workstation {
92 public:
93   /**
94    * @brief WorkstationVM consrtructor
95    * 
96    * @param model WorkstationModel associated to this Workstation
97    * @param name The name of the Workstation
98    * @param props Dictionary of properties associated to this Workstation
99    * @param netElm The RoutingEdge associated to this Workstation
100    * @param cpu The Cpu associated to this Workstation
101    */
102   WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
103                         RoutingEdgePtr netElm, CpuPtr cpu);
104
105   /**
106    * @brief WdorkstationVM destructor
107    */
108   ~WorkstationVM();
109
110   void setState(e_surf_resource_state_t state);
111
112   /**
113    * @brief Suspend the VM
114    */
115   virtual void suspend()=0;
116
117   /**
118    * @brief Resume the VM
119    */
120   virtual void resume()=0;
121
122   /**
123    * @brief Save the VM (Not yet implemented)
124    */
125   virtual void save()=0;
126
127   /**
128    * @brief Restore the VM (Not yet implemented)
129    */
130   virtual void restore()=0;
131
132   /**
133    * @brief Migrate the VM to the destination host
134    * 
135    * @param ind_vm_ws_dest The destination host
136    */
137   virtual void migrate(surf_resource_t ind_vm_ws_dest)=0;
138
139   /**
140    * @brief Get the physical machine hosting the VM
141    * @return The physical machine hosting the VM
142    */
143   virtual surf_resource_t getPm()=0;
144
145   virtual void setBound(double bound)=0;
146   virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
147
148   /* The workstation object of the lower layer */
149   CpuActionPtr p_action;
150   WorkstationPtr p_subWs;  // Pointer to the ''host'' OS
151   e_surf_vm_state_t p_currentState;
152 };
153
154 /**********
155  * Action *
156  **********/
157
158 #endif /* VM_WORKSTATION_INTERFACE_HPP_ */