summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorXuzhou Cheng2022-10-28 06:57:27 +0200
committerThomas Huth2022-10-28 11:17:12 +0200
commit84c662d2546feda2aeac21d09d4c71e8658062c0 (patch)
treefdb02c7c94bafe2d15a1ce305b1a85d243cc8dd5 /util
parentaccel/qtest: Support qtest accelerator for Windows (diff)
downloadqemu-84c662d2546feda2aeac21d09d4c71e8658062c0.tar.gz
qemu-84c662d2546feda2aeac21d09d4c71e8658062c0.tar.xz
qemu-84c662d2546feda2aeac21d09d4c71e8658062c0.zip
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 'util')
-rw-r--r--util/osdep.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/util/osdep.c b/util/osdep.c
index 746d5f7d71..77c1a6c562 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;