From: Takahiro Hirofuchi Date: Thu, 31 Jan 2013 20:48:10 +0000 (+0100) Subject: fix destroy() of vm_ws X-Git-Tag: v3_11_beta~297^2^2~118^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4cd446e94a6b7c4c7d15cb0b645124942223fb73 fix destroy() of vm_ws --- diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index a7b45bf002..3749e61bd4 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -282,7 +282,7 @@ typedef struct surf_vm_workstation_model_extension_public { // start does not appear here as it corresponds to turn the state from created to running (see smx_vm.c) int (*get_state) (void *workstation); void (*set_state) (void *workstation, int state); - void (*destroy) (const char *name); // destory the vm-specific data + void (*destroy) (smx_host_t *host); // destory the vm-specific data } s_surf_model_extension_vm_workstation_t; /** \ingroup SURF_models diff --git a/src/simix/smx_vm.c b/src/simix/smx_vm.c index 1aff24ed11..ff765eb511 100644 --- a/src/simix/smx_vm.c +++ b/src/simix/smx_vm.c @@ -96,10 +96,10 @@ void SIMIX_vm_destroy(smx_host_t host) smx_host_priv_t host_priv = SIMIX_host_priv(host); /* this will call the registered callback function, i.e., SIMIX_host_destroy(). */ - xbt_lib_unset(host_lib, name, SIMIX_HOST_LEVEL) + xbt_lib_unset(host_lib, hostname, SIMIX_HOST_LEVEL) /* jump to vm_ws_destroy(). The surf level resource will be freed. */ - surf_vm_workstation_model->extension.vm_workstation.destroy(hostname); + surf_vm_workstation_model->extension.vm_workstation.destroy(host); } void SIMIX_pre_vm_destroy(smx_simcall_t simcall, smx_host_t vm){ diff --git a/src/surf/vm_workstation.c b/src/surf/vm_workstation.c index 3bd63c33a3..d5cb5d61a0 100644 --- a/src/surf/vm_workstation.c +++ b/src/surf/vm_workstation.c @@ -32,23 +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 */ /* 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){