qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 27/51] tests/qtest: Use send/recv for socket communication


From: Thomas Huth
Subject: Re: [PATCH 27/51] tests/qtest: Use send/recv for socket communication
Date: Thu, 25 Aug 2022 15:04:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0

On 24/08/2022 11.40, Bin Meng wrote:
From: Xuzhou Cheng <xuzhou.cheng@windriver.com>

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>
---

  tests/qtest/libqmp.c   | 4 ++--
  tests/qtest/libqtest.c | 4 ++--
  2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/qtest/libqmp.c b/tests/qtest/libqmp.c
index ade26c15f0..995a39c1f8 100644
--- a/tests/qtest/libqmp.c
+++ b/tests/qtest/libqmp.c
@@ -36,7 +36,7 @@ typedef struct {
static void socket_send(int fd, const char *buf, size_t size)
  {
-    size_t res = qemu_write_full(fd, buf, size);
+    ssize_t res = send(fd, buf, size, 0);

This way we're losing the extra logic from qemu_write_full() here (i.e. the looping and EINTR handling) ... not sure whether that's really OK? Maybe you have to introduce a qemu_send_full() first?

 Thomas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]