-void surf_vm_workstation_save(surf_resource_t resource){
- get_casted_vm_workstation(resource)->save();
+void surf_vm_destroy(sg_host_t resource){
+ /* Before clearing the entries in host_lib, we have to pick up resources. */
+ const char* name = resource->id().c_str();
+ /* We deregister objects from host_lib, without invoking the freeing callback
+ * of each level.
+ *
+ * Do not call xbt_lib_remove() here. It deletes all levels of the key,
+ * including MSG_HOST_LEVEL and others. We should unregister only what we know.
+ */
+ sg_host_surfcpu_destroy(resource);
+ sg_host_edge_destroy(resource,1);
+ // TODO, use backlink from simgrid::surf::Host to simgrid::Host
+ simgrid::Host::by_name_or_null(name)->set_facet(SURF_HOST_LEVEL, nullptr);
+
+ /* TODO: comment out when VM storage is implemented. */
+ // host->set_facet(SURF_STORAGE_LEVEL, nullptr);