/* * vr_uvhost_del_fds_by_arg - deletes all FDs from the read/write lists matching * the given argument (pointer to a client). All the FDs found will be closed. * * Returns 0 on success, -1 otherwise. */ int vr_uvhost_del_fds_by_arg(void *arg) { int i; for (i = 0; i < MAX_UVHOST_FDS; i++) { if (uvh_rfds[i].uvh_fd > 0 && uvh_rfds[i].uvh_fd_arg == arg) vr_uvhost_del_fd(uvh_rfds[i].uvh_fd, UVH_FD_READ); if (uvh_wfds[i].uvh_fd > 0 && uvh_wfds[i].uvh_fd_arg == arg) vr_uvhost_del_fd(uvh_wfds[i].uvh_fd, UVH_FD_WRITE); } return 0; }
/* * vr_uvh_nl_vif_del_handler - handle a message from the netlink thread * to delete a vif. * * Returns 0 on success, -1 otherwise. */ int vr_uvh_nl_vif_del_handler(vrnu_vif_del_t *msg) { unsigned int cidx = msg->vrnu_vif_idx; vr_uvh_client_t *vru_cl; if (cidx >= VR_UVH_MAX_CLIENTS) { vr_uvhost_log("Couldn't delete vhost client due to bad index %d\n", cidx); return -1; } vr_dpdk_virtio_set_vif_client(cidx, NULL); vru_cl = vr_uvhost_get_client(cidx); if (vru_cl == NULL) { vr_uvhost_log("Couldn't find vhost client %d for deletion\n", cidx); return -1; } /* * Unmmaps Qemu's FD */ vr_dpdk_virtio_uvh_vif_munmap(&vr_dpdk_virtio_uvh_vif_mmap[cidx]); if (vru_cl->vruc_fd != -1) { vr_uvhost_del_fd(vru_cl->vruc_fd, UVH_FD_READ); } vr_uvhost_del_client(vru_cl); return 0; }
/* * vr_uvh_call_fd_handlers - call the handler for each FD that is set upon * return from poll(). * * Returns nothing. */ void vr_uvh_call_fd_handlers(struct pollfd *fds, nfds_t nfds) { unsigned int i; int ret; for (i = 0; i < nfds; i++) { if (fds[i].fd >= 0) { if (fds[i].revents & POLLIN) { ret = vr_uvh_call_fd_handlers_internal(uvh_rfds, fds[i].fd); if (ret) { vr_uvhost_del_fd(fds[i].fd, UVH_FD_READ); } } } } return; }