diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2020-12-15 14:56:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-15 14:56:32 +0000 |
commit | 8694149b351e3e125aa8f1740f8d5925e7ec112c (patch) | |
tree | 55fae56b5280eddd8c5c23d8c846fe36425e7ba2 /lib/tran_sock.h | |
parent | 3148a598f4ac0711d2f46ef9186e51a4779f1bf1 (diff) | |
download | libvfio-user-8694149b351e3e125aa8f1740f8d5925e7ec112c.zip libvfio-user-8694149b351e3e125aa8f1740f8d5925e7ec112c.tar.gz libvfio-user-8694149b351e3e125aa8f1740f8d5925e7ec112c.tar.bz2 |
send file descriptors for sparse areas in get region info (#201)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/tran_sock.h')
-rw-r--r-- | lib/tran_sock.h | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/lib/tran_sock.h b/lib/tran_sock.h index b764e9b..c4ed30c 100644 --- a/lib/tran_sock.h +++ b/lib/tran_sock.h @@ -92,6 +92,15 @@ vfu_recv(int sock, struct vfio_user_header *hdr, bool is_reply, uint16_t *msg_id, void *data, size_t *len); /* + * Same as vfu_recv except it receives passed file descriptors. See vfu_msg on + * the semantics of @fds and @nr_fds. + */ +int +vfu_recv_fds(int sock, struct vfio_user_header *hdr, bool is_reply, + uint16_t *msg_id, void *data, size_t *len, int *fds, + size_t *nr_fds); + +/* * Receive a message from the other end, but automatically allocate a buffer for * it, which must be freed by the caller. If there is no data, *datap is set to * NULL. @@ -105,16 +114,25 @@ vfu_recv_alloc(int sock, struct vfio_user_header *hdr, bool is_reply, * iovecs array should leave the first entry empty, as it will be used for the * header. * - * If specified, the given fds are sent to the other side. @hdr is filled with - * the reply header if non-NULL. + * If specified, the given @send_fds are sent to the other side. @hdr is filled + * with the reply header if non-NULL. + * + * @recv_fds and @recv_fd_count are used to receive file descriptors. + * If @recv_fd_count is NULL then @recv_fds is ignored and no file descriptors + * are received. If @recv_fd_count is non-NULL then it contains the number of + * file descriptors that can be stored in @recv_fds, in which case @recv_fds + * must point to sufficient memory. On return, @recv_fd_count contains the + * number of file decriptors actually received, which does not exceeed the + * original value of @recv_fd_count. */ int vfu_msg_iovec(int sock, uint16_t msg_id, enum vfio_user_command cmd, struct iovec *iovecs, size_t nr_iovecs, - int *send_fds, size_t fd_count, + int *send_fds, size_t send_fd_count, struct vfio_user_header *hdr, - void *recv_data, size_t recv_len); + void *recv_data, size_t recv_len, + int *recv_fds, size_t *recv_fd_count); /* * Send and receive a message to the other end. @hdr is filled with the reply @@ -127,6 +145,19 @@ vfu_msg(int sock, uint16_t msg_id, struct vfio_user_header *hdr, void *recv_data, size_t recv_len); +/* + * Same as vfu_msg excecpt that file descriptors can be received, see + * vfu_msg_iovec for the semantics of @recv_fds and @recv_fd_count. + */ +int +vfu_msg_fds(int sock, uint16_t msg_id, + enum vfio_user_command cmd, + void *send_data, size_t send_len, + struct vfio_user_header *hdr, + void *recv_data, size_t recv_len, + int *recv_fds, size_t *recv_fd_count); + + #endif /* LIB_VFIO_USER_TRAN_SOCK_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ |