diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-03-23 19:57:30 +0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-04-06 14:31:43 +0200 |
commit | c097f1e603c9deef308e17499b91dd6d552c2dfb (patch) | |
tree | 07cdbadf9d21ef19a1c7c58ce2147541bc34ec1b /include/qemu/coroutine.h | |
parent | 3bd04c091eb1cf2e01cd59e4e232b6b3bbdba15c (diff) | |
download | qemu-c097f1e603c9deef308e17499b91dd6d552c2dfb.zip qemu-c097f1e603c9deef308e17499b91dd6d552c2dfb.tar.gz qemu-c097f1e603c9deef308e17499b91dd6d552c2dfb.tar.bz2 |
include: move coroutine IO functions to coroutine.h
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220323155743.1585078-20-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qemu/coroutine.h')
-rw-r--r-- | include/qemu/coroutine.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index c828a95..284571b 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -343,4 +343,27 @@ void qemu_coroutine_decrease_pool_batch_size(unsigned int additional_pool_size); #include "qemu/lockable.h" +/** + * Sends a (part of) iovec down a socket, yielding when the socket is full, or + * Receives data into a (part of) iovec from a socket, + * yielding when there is no data in the socket. + * The same interface as qemu_sendv_recvv(), with added yielding. + * XXX should mark these as coroutine_fn + */ +ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt, + size_t offset, size_t bytes, bool do_send); +#define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \ + qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false) +#define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \ + qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true) + +/** + * The same as above, but with just a single buffer + */ +ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send); +#define qemu_co_recv(sockfd, buf, bytes) \ + qemu_co_send_recv(sockfd, buf, bytes, false) +#define qemu_co_send(sockfd, buf, bytes) \ + qemu_co_send_recv(sockfd, buf, bytes, true) + #endif /* QEMU_COROUTINE_H */ |