diff options
| author | Xuzhou Cheng <xuzhou.cheng@windriver.com> | 2022-10-28 12:57:27 +0800 |
|---|---|---|
| committer | Thomas Huth <thuth@redhat.com> | 2022-10-28 11:17:12 +0200 |
| commit | 84c662d2546feda2aeac21d09d4c71e8658062c0 (patch) | |
| tree | fdb02c7c94bafe2d15a1ce305b1a85d243cc8dd5 /tests/qtest/libqtest.c | |
| parent | c9923550b446e54413024117c0ed978a08e3ab1a (diff) | |
| download | focaccia-qemu-84c662d2546feda2aeac21d09d4c71e8658062c0.tar.gz focaccia-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 'tests/qtest/libqtest.c')
| -rw-r--r-- | tests/qtest/libqtest.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index b23eb3edc3..b01846fd98 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -27,6 +27,7 @@ #include "libqmp.h" #include "qemu/ctype.h" #include "qemu/cutils.h" +#include "qemu/sockets.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qlist.h" @@ -428,7 +429,7 @@ void qtest_quit(QTestState *s) static void socket_send(int fd, const char *buf, size_t size) { - size_t res = qemu_write_full(fd, buf, size); + ssize_t res = qemu_send_full(fd, buf, size); assert(res == size); } @@ -460,7 +461,7 @@ static GString *qtest_client_socket_recv_line(QTestState *s) ssize_t len; char buffer[1024]; - len = read(s->fd, buffer, sizeof(buffer)); + len = recv(s->fd, buffer, sizeof(buffer), 0); if (len == -1 && errno == EINTR) { continue; } |