+static int
+eth_vhost_update_intr(struct rte_eth_dev *eth_dev, uint16_t rxq_idx)
+{
+ struct rte_intr_handle *handle = eth_dev->intr_handle;
+ struct rte_epoll_event rev;
+ int epfd, ret;
+
+ if (!handle)
+ return 0;
+
+ if (handle->efds[rxq_idx] == handle->elist[rxq_idx].fd)
+ return 0;
+
+ VHOST_LOG(INFO, "kickfd for rxq-%d was changed, updating handler.\n",
+ rxq_idx);
+
+ if (handle->elist[rxq_idx].fd != -1)
+ VHOST_LOG(ERR, "Unexpected previous kickfd value (Got %d, expected -1).\n",
+ handle->elist[rxq_idx].fd);
+
+ /*
+ * First remove invalid epoll event, and then install
+ * the new one. May be solved with a proper API in the
+ * future.
+ */
+ epfd = handle->elist[rxq_idx].epfd;
+ rev = handle->elist[rxq_idx];
+ ret = rte_epoll_ctl(epfd, EPOLL_CTL_DEL, rev.fd,
+ &handle->elist[rxq_idx]);
+ if (ret) {
+ VHOST_LOG(ERR, "Delete epoll event failed.\n");
+ return ret;
+ }
+
+ rev.fd = handle->efds[rxq_idx];
+ handle->elist[rxq_idx] = rev;
+ ret = rte_epoll_ctl(epfd, EPOLL_CTL_ADD, rev.fd,
+ &handle->elist[rxq_idx]);
+ if (ret) {
+ VHOST_LOG(ERR, "Add epoll event failed.\n");
+ return ret;
+ }
+
+ return 0;
+}
+