| 2689 | } |
| 2690 | |
| 2691 | static int |
| 2692 | vhost_user_set_postcopy_advise(struct virtio_net **pdev, |
| 2693 | struct vhu_msg_context *ctx, |
| 2694 | int main_fd __rte_unused) |
| 2695 | { |
| 2696 | struct virtio_net *dev = *pdev; |
| 2697 | #ifdef RTE_LIBRTE_VHOST_POSTCOPY |
| 2698 | struct uffdio_api api_struct; |
| 2699 | |
| 2700 | dev->postcopy_ufd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK); |
| 2701 | |
| 2702 | if (dev->postcopy_ufd == -1) { |
| 2703 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 2704 | "userfaultfd not available: %s\n", |
| 2705 | strerror(errno)); |
| 2706 | return RTE_VHOST_MSG_RESULT_ERR; |
| 2707 | } |
| 2708 | api_struct.api = UFFD_API; |
| 2709 | api_struct.features = 0; |
| 2710 | if (ioctl(dev->postcopy_ufd, UFFDIO_API, &api_struct)) { |
| 2711 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 2712 | "UFFDIO_API ioctl failure: %s\n", |
| 2713 | strerror(errno)); |
| 2714 | close(dev->postcopy_ufd); |
| 2715 | dev->postcopy_ufd = -1; |
| 2716 | return RTE_VHOST_MSG_RESULT_ERR; |
| 2717 | } |
| 2718 | ctx->fds[0] = dev->postcopy_ufd; |
| 2719 | ctx->fd_num = 1; |
| 2720 | |
| 2721 | return RTE_VHOST_MSG_RESULT_REPLY; |
| 2722 | #else |
| 2723 | dev->postcopy_ufd = -1; |
| 2724 | ctx->fd_num = 0; |
| 2725 | |
| 2726 | return RTE_VHOST_MSG_RESULT_ERR; |
| 2727 | #endif |
| 2728 | } |
| 2729 | |
| 2730 | static int |
| 2731 | vhost_user_set_postcopy_listen(struct virtio_net **pdev, |