/* * \brief Destroys a host (internal call only) */ void __MSG_host_destroy(msg_host_t host) { const char *name = MSG_host_get_name(host); /* TODO: * What happens if VMs still remain on this host? * Revisit here after the surf layer gets stable. **/ xbt_lib_unset(host_lib, name, MSG_HOST_LEVEL, 1); }
/** \ingroup msg_file_management * \brief Close the file * * \param fd is the file to close * \return 0 on success or 1 on error */ int MSG_file_close(msg_file_t fd) { char *name; msg_file_priv_t priv = MSG_file_priv(fd); if (priv->data) xbt_free(priv->data); int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self()); name = bprintf("%s:%i:%s",MSG_host_get_name(MSG_host_self()),MSG_process_self_PID(),priv->fullpath); xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1); xbt_free(name); return res; }
/* * Update the physical host of the given VM */ void VMHL13::migrate(surf_resource_t ind_dst_pm) { /* ind_dst_pm equals to smx_host_t */ HostPtr ws_dst = static_cast<HostPtr>(surf_host_resource_priv(ind_dst_pm)); const char *vm_name = getName(); const char *pm_name_src = p_subWs->getName(); const char *pm_name_dst = ws_dst->getName(); xbt_assert(ws_dst); /* do something */ /* update net_elm with that of the destination physical host */ RoutingEdgePtr old_net_elm = p_netElm; RoutingEdgePtr new_net_elm = new RoutingEdgeWrapper(static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, pm_name_dst, ROUTING_HOST_LEVEL))); xbt_assert(new_net_elm); /* Unregister the current net_elm from host_lib. Do not call the free callback. */ xbt_lib_unset(host_lib, vm_name, ROUTING_HOST_LEVEL, 0); /* Then, resister the new one. */ p_netElm = new_net_elm; xbt_lib_set(host_lib, vm_name, ROUTING_HOST_LEVEL, p_netElm); p_subWs = ws_dst; /* Update vcpu's action for the new pm */ { #if 0 XBT_INFO("cpu_action->remains %g", p_action->remains); XBT_INFO("cost %f remains %f start %f finish %f", p_action->cost, p_action->remains, p_action->start, p_action->finish ); XBT_INFO("cpu_action state %d", surf_action_get_state(p_action)); #endif /* create a cpu action bound to the pm model at the destination. */ CpuActionPtr new_cpu_action = static_cast<CpuActionPtr>( static_cast<CpuPtr>(surf_cpu_resource_priv(ind_dst_pm))->execute(0)); e_surf_action_state_t state = p_action->getState(); if (state != SURF_ACTION_DONE) XBT_CRITICAL("FIXME: may need a proper handling, %d", state); if (p_action->getRemainsNoUpdate() > 0) XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->getRemainsNoUpdate()); /* keep the bound value of the cpu action of the VM. */ double old_bound = p_action->getBound(); if (old_bound != 0) { XBT_DEBUG("migrate VM(%s): set bound (%f) at %s", vm_name, old_bound, pm_name_dst); new_cpu_action->setBound(old_bound); } _XBT_GNUC_UNUSED int ret = p_action->unref(); xbt_assert(ret == 1, "Bug: some resource still remains"); p_action = new_cpu_action; } XBT_DEBUG("migrate VM(%s): change net_elm (%p to %p)", vm_name, old_net_elm, new_net_elm); XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst); delete old_net_elm; }