Vhost session relates vhost communication layer to virtio-net device layer. Because vhost-cuse and vhost-user have different session information, the patch is needed.
Signed-off-by: Tetsuya Mukawa <mukawa at igel.co.jp> --- lib/librte_vhost/rte_virtio_net.h | 2 +- lib/librte_vhost/vhost-net-cdev.c | 8 ++++---- lib/librte_vhost/vhost-net.h | 7 ++++++- lib/librte_vhost/virtio-net-cdev.c | 7 ++++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h index a36c0e3..a9e20ea 100644 --- a/lib/librte_vhost/rte_virtio_net.h +++ b/lib/librte_vhost/rte_virtio_net.h @@ -85,7 +85,7 @@ struct vhost_driver { vhost_driver_type_t type; /**< driver type. */ const char *dev_name; /**< accessing device name. */ union { - struct fuse_session *session; /**< fuse session. */ + struct fuse_session *cuse_session; /**< fuse session. */ }; }; diff --git a/lib/librte_vhost/vhost-net-cdev.c b/lib/librte_vhost/vhost-net-cdev.c index 090c6fc..6754548 100644 --- a/lib/librte_vhost/vhost-net-cdev.c +++ b/lib/librte_vhost/vhost-net-cdev.c @@ -67,7 +67,7 @@ fuse_req_to_vhost_ctx(fuse_req_t req, struct fuse_file_info *fi) struct fuse_ctx const *const req_ctx = fuse_req_ctx(req); ctx.type = VHOST_DRV_CUSE; - ctx.pid = req_ctx->pid; + ctx.cdev.pid = req_ctx->pid; ctx.fh = fi->fh; return ctx; @@ -345,9 +345,9 @@ vhost_cuse_driver_register(struct vhost_driver *drv) ops = get_virtio_net_callbacks(drv->type); - drv->session = cuse_lowlevel_setup(3, fuse_argv, + drv->cuse_session = cuse_lowlevel_setup(3, fuse_argv, &cuse_info, &vhost_net_ops, 0, NULL); - if (drv->session == NULL) + if (drv->cuse_session == NULL) return -1; return 0; @@ -359,7 +359,7 @@ vhost_cuse_driver_register(struct vhost_driver *drv) static int vhost_cuse_driver_session_start(struct vhost_driver *drv) { - fuse_session_loop(drv->session); + fuse_session_loop(drv->cuse_session); return 0; } diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h index 64873d0..ef04832 100644 --- a/lib/librte_vhost/vhost-net.h +++ b/lib/librte_vhost/vhost-net.h @@ -72,14 +72,19 @@ #define PRINT_PACKET(device, addr, size, header) do {} while (0) #endif +struct vhost_device_cuse_ctx { + pid_t pid; /* PID of process calling the IOCTL. */ +}; /* * Structure used to identify device context. */ struct vhost_device_ctx { vhost_driver_type_t type; /* driver type. */ - pid_t pid; /* PID of process calling the IOCTL. */ uint64_t fh; /* Populated with fi->fh to track the device index. */ + union { + struct vhost_device_cuse_ctx cdev; + }; }; /* diff --git a/lib/librte_vhost/virtio-net-cdev.c b/lib/librte_vhost/virtio-net-cdev.c index 70bc578..ac97551 100644 --- a/lib/librte_vhost/virtio-net-cdev.c +++ b/lib/librte_vhost/virtio-net-cdev.c @@ -412,7 +412,8 @@ cuse_set_mem_table(struct vhost_device_ctx ctx, const void *mem_regions_addr, if (mem->regions[regionidx].guest_phys_address == 0x0) { mem->base_address = mem->regions[regionidx].userspace_address; /* Map VM memory file */ - if (cdev_host_memory_map(dev, mem, ctx.pid, mem->base_address) != 0) { + if (cdev_host_memory_map(dev, mem, ctx.cdev.pid, + mem->base_address) != 0) { free(mem); return -1; } @@ -543,7 +544,7 @@ cuse_set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file) vq->kickfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); eventfd_kick.source_fd = vq->kickfd; eventfd_kick.target_fd = file->fd; - eventfd_kick.target_pid = ctx.pid; + eventfd_kick.target_pid = ctx.cdev.pid; if (eventfd_copy(dev, &eventfd_kick)) return -1; @@ -577,7 +578,7 @@ cuse_set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file) vq->callfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); eventfd_call.source_fd = vq->callfd; eventfd_call.target_fd = file->fd; - eventfd_call.target_pid = ctx.pid; + eventfd_call.target_pid = ctx.cdev.pid; if (eventfd_copy(dev, &eventfd_call)) return -1; -- 1.9.1