From 84c662d2546feda2aeac21d09d4c71e8658062c0 Mon Sep 17 00:00:00 2001 From: Xuzhou Cheng Date: Fri, 28 Oct 2022 12:57:27 +0800 Subject: tests/qtest: Use send/recv for socket communication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau Message-Id: <20221028045736.679903-3-bin.meng@windriver.com> Signed-off-by: Thomas Huth --- util/osdep.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'util') diff --git a/util/osdep.c b/util/osdep.c index 746d5f7..77c1a6c 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -502,6 +502,28 @@ int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen) return ret; } +ssize_t qemu_send_full(int s, const void *buf, size_t count) +{ + ssize_t ret = 0; + ssize_t total = 0; + + while (count) { + ret = send(s, buf, count, 0); + if (ret < 0) { + if (errno == EINTR) { + continue; + } + break; + } + + count -= ret; + buf += ret; + total += ret; + } + + return total; +} + void qemu_set_hw_version(const char *version) { hw_version = version; -- cgit v1.1