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 * A physical host does not disapper in the current SimGrid code, but a VM may
29 * disapper during a simulation.
31 WorkstationVM::~WorkstationVM()
33 /* ind_phys_workstation equals to smx_host_t */
34 surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
36 /* Before clearing the entries in host_lib, we have to pick up resources. */
37 CpuCas01Ptr cpu = dynamic_cast<CpuCas01Ptr>(
38 static_cast<ResourcePtr>(
39 surf_cpu_resource_priv(ind_vm_workstation)));
41 /* We deregister objects from host_lib, without invoking the freeing callback
44 * Do not call xbt_lib_remove() here. It deletes all levels of the key,
45 * including MSG_HOST_LEVEL and others. We should unregister only what we know.
47 xbt_lib_unset(host_lib, getName(), SURF_CPU_LEVEL, 0);
48 xbt_lib_unset(host_lib, getName(), ROUTING_HOST_LEVEL, 0);
49 xbt_lib_unset(host_lib, getName(), SURF_WKS_LEVEL, 0);
51 /* TODO: comment out when VM stroage is implemented. */
52 // xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
55 /* Free the cpu_action of the VM. */
56 int ret = p_action->unref();
57 xbt_assert(ret == 1, "Bug: some resource still remains");
59 /* Free the cpu resource of the VM. If using power_trace, we will have to */
64 * A surf level object will be useless in the upper layer. Returing the
65 * dict_elm of the host.
67 surf_resource_t WorkstationVM::getPm()
69 return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
76 //FIME:: handle action cancel