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