aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorXuzhou Cheng <xuzhou.cheng@windriver.com>2022-10-28 12:57:27 +0800
committerThomas Huth <thuth@redhat.com>2022-10-28 11:17:12 +0200
commit84c662d2546feda2aeac21d09d4c71e8658062c0 (patch)
treefdb02c7c94bafe2d15a1ce305b1a85d243cc8dd5 /include
parentc9923550b446e54413024117c0ed978a08e3ab1a (diff)
downloadqemu-84c662d2546feda2aeac21d09d4c71e8658062c0.zip
qemu-84c662d2546feda2aeac21d09d4c71e8658062c0.tar.gz
qemu-84c662d2546feda2aeac21d09d4c71e8658062c0.tar.bz2
tests/qtest: Use send/recv for socket communication
Socket communication in the libqtest and libqmp codes uses read() and write() which work on any file descriptor on *nix, and sockets in *nix are an example of a file descriptor. However sockets on Windows do not use *nix-style file descriptors, so read() and write() cannot be used on sockets on Windows. Switch over to use send() and recv() instead which work on both Windows and *nix. Signed-off-by: Xuzhou Cheng <xuzhou.cheng@windriver.com> Signed-off-by: Bin Meng <bin.meng@windriver.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20221028045736.679903-3-bin.meng@windriver.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/sockets.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 036745e..61648f3 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -33,6 +33,19 @@ int qemu_socketpair(int domain, int type, int protocol, int sv[2]);
#endif
int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
+/*
+ * A variant of send(2) which handles partial send.
+ *
+ * Return the number of bytes transferred over the socket.
+ * Set errno if fewer than `count' bytes are sent.
+ *
+ * This function don't work with non-blocking socket's.
+ * Any of the possibilities with non-blocking socket's is bad:
+ * - return a short write (then name is wrong)
+ * - busy wait adding (errno == EAGAIN) to the loop
+ */
+ssize_t qemu_send_full(int s, const void *buf, size_t count)
+ G_GNUC_WARN_UNUSED_RESULT;
int socket_set_cork(int fd, int v);
int socket_set_nodelay(int fd);
void qemu_socket_set_block(int fd);