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.
15 void surf_vm_workstation_model_init(void);
21 class WorkstationVMModel;
22 typedef WorkstationVMModel *WorkstationVMModelPtr;
25 typedef WorkstationVM *WorkstationVMPtr;
27 class WorkstationVMLmm;
28 typedef WorkstationVMLmm *WorkstationVMLmmPtr;
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)`
38 extern surf_callback(void, WorkstationVMPtr) workstationVMCreatedCallbacks;
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)`
44 extern surf_callback(void, WorkstationVMPtr) workstationVMDestructedCallbacks;
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)`
50 extern surf_callback(void, WorkstationVMPtr) workstationVMStateChangedCallbacks;
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
59 class WorkstationVMModel : public WorkstationModel {
62 * @brief WorkstationVMModel consrtuctor
67 * @brief WorkstationVMModel consrtuctor
69 ~WorkstationVMModel(){};
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 void createResource(const char *name, void *ind_phys_workstation)=0;
80 void adjustWeightOfDummyCpuActions() {};
82 typedef boost::intrusive::list<WorkstationVM,
83 boost::intrusive::constant_time_size<false> >
85 static vm_list_t ws_vms;
92 /** @ingroup SURF_vm_workstation_interface
93 * @brief SURF workstation VM interface class
94 * @details A workstation VM represent an virtual machine
96 class WorkstationVM : public Workstation,
97 public boost::intrusive::list_base_hook<> {
100 * @brief WorkstationVM consrtructor
102 * @param model WorkstationModel associated to this Workstation
103 * @param name The name of the Workstation
104 * @param props Dictionary of properties associated to this Workstation
105 * @param netElm The RoutingEdge associated to this Workstation
106 * @param cpu The Cpu associated to this Workstation
108 WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
109 RoutingEdgePtr netElm, CpuPtr cpu);
112 * @brief WdorkstationVM destructor
116 void setState(e_surf_resource_state_t state);
119 * @brief Suspend the VM
121 virtual void suspend()=0;
124 * @brief Resume the VM
126 virtual void resume()=0;
129 * @brief Save the VM (Not yet implemented)
131 virtual void save()=0;
134 * @brief Restore the VM (Not yet implemented)
136 virtual void restore()=0;
139 * @brief Migrate the VM to the destination host
141 * @param ind_vm_ws_dest The destination host
143 virtual void migrate(surf_resource_t ind_vm_ws_dest)=0;
146 * @brief Get the physical machine hosting the VM
147 * @return The physical machine hosting the VM
149 virtual surf_resource_t getPm()=0;
151 virtual void setBound(double bound)=0;
152 virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
154 /* The workstation object of the lower layer */
155 CpuActionPtr p_action;
156 WorkstationPtr p_subWs; // Pointer to the ''host'' OS
157 e_surf_vm_state_t p_currentState;
164 #endif /* VM_WORKSTATION_INTERFACE_HPP_ */