4 * Created on: Nov 12, 2013
7 #include "workstation.hpp"
9 #ifndef VM_WORKSTATION_HPP_
10 #define VM_WORKSTATION_HPP_
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.
15 void surf_vm_workstation_model_init(void);
18 void (*create) (const char *name, void *ind_phys_workstation); // First operation of the VM model
19 void (*destroy) (void *ind_vm_ws); // will be vm_ws_destroy(), which destroies the vm-workstation-specific data
21 void (*suspend) (void *ind_vm_ws);
22 void (*resume) (void *ind_vm_ws);
24 void (*save) (void *ind_vm_ws);
25 void (*restore) (void *ind_vm_ws);
27 void (*migrate) (void *ind_vm_ws, void *ind_vm_ws_dest); // will be vm_ws_migrate()
29 int (*get_state) (void *ind_vm_ws);
30 void (*set_state) (void *ind_vm_ws, int state);
32 void * (*get_pm) (void *ind_vm_ws); // will be vm_ws_get_pm()
34 void (*set_vm_bound) (void *ind_vm_ws, double bound); // will be vm_ws_set_vm_bound()
35 void (*set_vm_affinity) (void *ind_vm_ws, void *ind_pm_ws, unsigned long mask); // will be vm_ws_set_vm_affinity()
42 class WorkstationVMModel;
43 typedef WorkstationVMModel *WorkstationVMModelPtr;
45 class WorkstationVM2013;
46 typedef WorkstationVM2013 *WorkstationVM2013Ptr;
48 class WorkstationVM2013Lmm;
49 typedef WorkstationVM2013Lmm *WorkstationVM2013LmmPtr;
58 class WorkstationVMModel : public WorkstationModel {
61 ~WorkstationVMModel(){};
62 void createResource(const char *name, void *ind_phys_workstation);
63 double shareResources(double now);
64 void adjustWeightOfDummyCpuActions() {};
70 class WorkstationVM2013 : virtual public WorkstationCLM03 {
72 WorkstationVM2013(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
73 : WorkstationCLM03(model, name, props, NULL, netElm, cpu) {};
75 virtual void suspend()=0;
76 virtual void resume()=0;
78 virtual void save()=0;
79 virtual void restore()=0;
81 virtual void migrate(surf_resource_t ind_vm_ws_dest)=0; // will be vm_ws_migrate()
83 virtual surf_resource_t getPm()=0; // will be vm_ws_get_pm()
85 virtual void setBound(double bound)=0;
86 virtual void setAffinity(CpuLmmPtr cpu, unsigned long mask)=0;
88 /* The workstation object of the lower layer */
89 WorkstationCLM03Ptr p_subWs; // Pointer to the ''host'' OS
90 e_surf_vm_state_t p_currentState;
91 CpuActionLmmPtr p_action;
94 class WorkstationVM2013Lmm : public WorkstationVM2013, public WorkstationCLM03Lmm {
96 WorkstationVM2013Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, surf_resource_t ind_phys_workstation);
97 ~WorkstationVM2013Lmm();
105 void migrate(surf_resource_t ind_dst_pm);
107 e_surf_resource_state_t getState();
108 void setState(e_surf_resource_state_t state);
110 surf_resource_t getPm(); // will be vm_ws_get_pm()
112 void setBound(double bound);
113 void setAffinity(CpuLmmPtr cpu, unsigned long mask);
116 void updateState(tmgr_trace_event_t event_type, double value, double date) {
117 WorkstationCLM03Lmm::updateState(event_type, value, date);
120 return WorkstationCLM03Lmm::isUsed();
122 xbt_dict_t getProperties() {
123 return WorkstationCLM03Lmm::getProperties();
125 ActionPtr execute(double size);
133 #endif /* VM_WORKSTATION_HPP_ */