1 /* Copyright (c) 2004-2014. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "workstation_interface.hpp"
9 #ifndef VM_WORKSTATION_INTERFACE_HPP_
10 #define VM_WORKSTATION_INTERFACE_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.
19 class WorkstationVMModel;
20 typedef WorkstationVMModel *WorkstationVMModelPtr;
23 typedef WorkstationVM *WorkstationVMPtr;
25 class WorkstationVMLmm;
26 typedef WorkstationVMLmm *WorkstationVMLmmPtr;
32 /** @ingroup SURF_callbacks
33 * @brief Callbacks handler which emit the callbacks after WorkstationVM creation *
34 * @details Callback functions have the following signature: `void(WorkstationVMPtr)`
36 extern surf_callback(void, WorkstationVMPtr) workstationVMCreatedCallbacks;
38 /** @ingroup SURF_callbacks
39 * @brief Callbacks handler which emit the callbacks after WorkstationVM destruction *
40 * @details Callback functions have the following signature: `void(WorkstationVMPtr)`
42 extern surf_callback(void, WorkstationVMPtr) workstationVMDestructedCallbacks;
44 /** @ingroup SURF_callbacks
45 * @brief Callbacks handler which emit the callbacks after WorkstationVM State changed *
46 * @details Callback functions have the following signature: `void(WorkstationVMActionPtr)`
48 extern surf_callback(void, WorkstationVMPtr) workstationVMStateChangedCallbacks;
53 /** @ingroup SURF_vm_workstation_interface
54 * @brief SURF workstation VM model interface class
55 * @details A model is an object which handle the interactions between its Resources and its Actions
57 class WorkstationVMModel : public WorkstationModel {
60 * @brief WorkstationVMModel consrtuctor
65 * @brief WorkstationVMModel consrtuctor
67 ~WorkstationVMModel(){};
69 WorkstationPtr createWorkstation(const char *name){DIE_IMPOSSIBLE;}
72 * @brief Create a new WorkstationVM
74 * @param name The name of the new WorkstationVM
75 * @param ind_phys_workstation The workstation hosting the VM
78 virtual WorkstationVMPtr createWorkstationVM(const char *name, surf_resource_t ind_phys_workstation)=0;
79 void adjustWeightOfDummyCpuActions() {};
81 typedef boost::intrusive::list<WorkstationVM,
82 boost::intrusive::constant_time_size<false> >
84 static vm_list_t ws_vms;
91 /** @ingroup SURF_vm_workstation_interface
92 * @brief SURF workstation VM interface class
93 * @details A workstation VM represent an virtual machine
95 class WorkstationVM : public Workstation,
96 public boost::intrusive::list_base_hook<> {
99 * @brief WorkstationVM consrtructor
101 * @param model WorkstationModel associated to this Workstation
102 * @param name The name of the Workstation
103 * @param props Dictionary of properties associated to this Workstation
104 * @param netElm The RoutingEdge associated to this Workstation
105 * @param cpu The Cpu associated to this Workstation
107 WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
108 RoutingEdgePtr netElm, CpuPtr cpu);
111 * @brief WdorkstationVM destructor
115 void setState(e_surf_resource_state_t state);
118 * @brief Suspend the VM
120 virtual void suspend()=0;
123 * @brief Resume the VM
125 virtual void resume()=0;
128 * @brief Save the VM (Not yet implemented)
130 virtual void save()=0;
133 * @brief Restore the VM (Not yet implemented)
135 virtual void restore()=0;
138 * @brief Migrate the VM to the destination host
140 * @param ind_vm_ws_dest The destination host
142 virtual void migrate(surf_resource_t ind_vm_ws_dest)=0;
145 * @brief Get the physical machine hosting the VM
146 * @return The physical machine hosting the VM
148 virtual surf_resource_t getPm()=0;
150 virtual void setBound(double bound)=0;
151 virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
153 /* The workstation object of the lower layer */
154 CpuActionPtr p_action;
155 WorkstationPtr p_subWs; // Pointer to the ''host'' OS
156 e_surf_vm_state_t p_currentState;
163 #endif /* VM_WORKSTATION_INTERFACE_HPP_ */