4 * Created on: Nov 12, 2013
7 #include "vm_workstation_interface.hpp"
8 #include "cpu_cas01.hpp"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm_workstation, surf,
11 "Logging specific to the SURF VM workstation module");
13 WorkstationVMModelPtr surf_vm_workstation_model = NULL;
19 WorkstationVMModel::WorkstationVMModel() : WorkstationModel("Virtual Workstation") {
20 p_cpuModel = surf_cpu_model_vm;
28 WorkstationVMLmm::WorkstationVMLmm(RoutingEdgePtr netElm, CpuPtr cpu)
29 : WorkstationVM(netElm, cpu)
34 * A physical host does not disapper in the current SimGrid code, but a VM may
35 * disapper during a simulation.
37 WorkstationVM::~WorkstationVM()
39 /* ind_phys_workstation equals to smx_host_t */
40 surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
42 /* Before clearing the entries in host_lib, we have to pick up resources. */
43 CpuCas01LmmPtr cpu = dynamic_cast<CpuCas01LmmPtr>(
44 static_cast<ResourcePtr>(
45 surf_cpu_resource_priv(ind_vm_workstation)));
47 /* We deregister objects from host_lib, without invoking the freeing callback
50 * Do not call xbt_lib_remove() here. It deletes all levels of the key,
51 * including MSG_HOST_LEVEL and others. We should unregister only what we know.
53 xbt_lib_unset(host_lib, getName(), SURF_CPU_LEVEL, 0);
54 xbt_lib_unset(host_lib, getName(), ROUTING_HOST_LEVEL, 0);
55 xbt_lib_unset(host_lib, getName(), SURF_WKS_LEVEL, 0);
57 /* TODO: comment out when VM stroage is implemented. */
58 // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
61 /* Free the cpu_action of the VM. */
62 int ret = p_action->unref();
63 xbt_assert(ret == 1, "Bug: some resource still remains");
65 /* Free the cpu resource of the VM. If using power_trace, we will have to */
70 * A surf level object will be useless in the upper layer. Returing the
71 * dict_elm of the host.
73 surf_resource_t WorkstationVM::getPm()
75 return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
82 //FIME:: handle action cancel