Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix destroy() of vm_ws
[simgrid.git] / src / surf / vm_workstation.c
index 1db863ce36e4d25c1cc6dba6df29a5c659c536ab..d5cb5d61a059d3ee7e1e7572fe2b6b2cdc33a875 100644 (file)
@@ -32,22 +32,25 @@ static void vm_ws_create (const char *name, void *phys_workstation)
   vm_ws->current_state=msg_vm_state_created,
   xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, vm_ws);
 }
+
+
 /*
  * A physical host does not disapper in the current SimGrid code, but a VM may
  * disapper during a simulation.
  */
-static void vm_ws_destroy(const char *name)
-{
-       workstation_VM2013_t workstation = xbt_lib_get_or_null(host_lib, name, SURF_WKS_LEVEL);
-       xbt_assert(workstation);
-       xbt_assert(workstation->generic_resource.model == surf_vm_workstation_model);
-
-       xbt_free(workstation->generic_resource.name);
+static void vm_ws_destroy(smx_host_t host)
+{ 
+       workstation_VM2013_t vm_ws = surf_workstation_resource_priv(host);
+       xbt_assert(vm_ws);
+       xbt_assert(vm_ws->generic_resource.model == surf_vm_workstation_model);
 
+       const char *name = vm_ws->generic_resource.name;
        /* not defined yet, but we should have  */
-       // xbt_lib_unset(host_lib, name, SURF_WKS_LEVEL);
+       /* this will call surf_resource_free() */
+       xbt_lib_unset(host_lib, name, SURF_WKS_LEVEL);
 
-       xbt_free(workstation);
+       xbt_free(vm_ws->generic_resource.name);
+       xbt_free(vm_ws);
 }
 
 static int vm_ws_get_state(void *vm_ws){