Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Check return value for posix_memalign.
[simgrid.git] / src / surf / vm_workstation_interface.cpp
1 /* Copyright (c) 2013-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 "vm_workstation_interface.hpp"
8 #include "cpu_cas01.hpp"
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm_workstation, surf,
11                                 "Logging specific to the SURF VM workstation module");
12
13 WorkstationVMModelPtr surf_vm_workstation_model = NULL;
14
15 /*************
16  * Callbacks *
17  *************/
18
19 surf_callback(void, WorkstationVMPtr) workstationVMCreatedCallbacks;
20 surf_callback(void, WorkstationVMPtr) workstationVMDestructedCallbacks;
21 surf_callback(void, WorkstationVMPtr) workstationVMStateChangedCallbacks;
22
23 /*********
24  * Model *
25  *********/
26
27 WorkstationVMModel::WorkstationVMModel() : WorkstationModel("Virtual Workstation") {
28   p_cpuModel = surf_cpu_model_vm;
29 }
30
31 WorkstationVMModel::vm_list_t WorkstationVMModel::ws_vms;
32
33 /************
34  * Resource *
35  ************/
36
37 WorkstationVM::WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
38                         RoutingEdgePtr netElm, CpuPtr cpu)
39 : Workstation(model, name, props, NULL, netElm, cpu)
40 {
41   WorkstationVMModel::ws_vms.push_back(*this);
42   surf_callback_emit(workstationVMCreatedCallbacks, this);
43 }
44
45 /*
46  * A physical host does not disapper in the current SimGrid code, but a VM may
47  * disapper during a simulation.
48  */
49 WorkstationVM::~WorkstationVM()
50 {
51   surf_callback_emit(workstationVMDestructedCallbacks, this);
52   WorkstationVMModel::ws_vms.erase(WorkstationVMModel::
53                                    vm_list_t::s_iterator_to(*this));
54 }
55
56 void WorkstationVM::setState(e_surf_resource_state_t state){
57   Resource::setState(state);
58   surf_callback_emit(workstationVMStateChangedCallbacks, this);
59 }
60
61 /*
62  * A surf level object will be useless in the upper layer. Returing the
63  * dict_elm of the host.
64  **/
65 surf_resource_t WorkstationVM::getPm()
66 {
67   return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
68 }
69
70 /**********
71  * Action *
72  **********/
73
74 //FIME:: handle action cancel
75