Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'torus'
[simgrid.git] / src / surf / vm_workstation_interface.hpp
1 /* Copyright (c) 2004-2013. 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  * Model *
32  *********/
33 /** @ingroup SURF_vm_workstation_interface
34  * @brief SURF workstation VM model interface class
35  * @details A model is an object which handle the interactions between its Resources and its Actions
36  */
37 class WorkstationVMModel : public WorkstationModel {
38 public:
39   /**
40    * @brief WorkstationVMModel consrtuctor
41    */
42   WorkstationVMModel();
43
44     /**
45    * @brief WorkstationVMModel consrtuctor
46    */
47   ~WorkstationVMModel(){};
48
49   /**
50    * @brief Create a new WorkstationVM
51    * 
52    * @param name The name of the new WorkstationVM
53    * @param ind_phys_workstation The workstation hosting the VM
54    * 
55    */
56   virtual void createResource(const char *name, void *ind_phys_workstation)=0;
57
58
59   void adjustWeightOfDummyCpuActions() {};
60 };
61
62 /************
63  * Resource *
64  ************/
65
66 /** @ingroup SURF_vm_workstation_interface
67  * @brief SURF workstation VM interface class
68  * @details A workstation VM represent an virtual machine
69  */
70 class WorkstationVM : public Workstation {
71 public:
72   /**
73    * @brief WorkstationVM consrtructor
74    * 
75    * @param model WorkstationModel associated to this Workstation
76    * @param name The name of the Workstation
77    * @param props Dictionary of properties associated to this Workstation
78    * @param netElm The RoutingEdge associated to this Workstation
79    * @param cpu The Cpu associated to this Workstation
80    */
81   WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
82                         RoutingEdgePtr netElm, CpuPtr cpu)
83   : Workstation(model, name, props, NULL, netElm, cpu) {}
84
85   /**
86    * @brief WdorkstationVM estructor
87    */
88   ~WorkstationVM();
89
90   /**
91    * @brief Suspend the VM
92    */
93   virtual void suspend()=0;
94
95   /**
96    * @brief Resume the VM
97    */
98   virtual void resume()=0;
99
100   /**
101    * @brief Save the VM (Not yet implemented)
102    */
103   virtual void save()=0;
104
105   /**
106    * @brief Restore the VM (Not yet implemented)
107    */
108   virtual void restore()=0;
109
110   /**
111    * @brief Migrate the VM to the destination host
112    * 
113    * @param ind_vm_ws_dest The destination host
114    */
115   virtual void migrate(surf_resource_t ind_vm_ws_dest)=0;
116
117   /**
118    * @brief Get the physical machine hosting the VM
119    * @return The physical machine hosting the VM
120    */
121   virtual surf_resource_t getPm()=0;
122
123   virtual void setBound(double bound)=0;
124   virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
125
126   /* The workstation object of the lower layer */
127   CpuActionPtr p_action;
128   WorkstationPtr p_subWs;  // Pointer to the ''host'' OS
129   e_surf_vm_state_t p_currentState;
130 };
131
132 /**********
133  * Action *
134  **********/
135
136 #endif /* VM_WORKSTATION_INTERFACE_HPP_ */