On Tue, Oct 18, 2022 at 06:09:28PM +0100, Peter Maydell wrote: > On Thu, 6 Oct 2022 at 17:20, Bin Meng <bmeng...@gmail.com> wrote: > > > > From: Xuzhou Cheng <xuzhou.ch...@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.ch...@windriver.com> > > Signed-off-by: Bin Meng <bin.m...@windriver.com> > > Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com> > > --- > > > > (no changes since v2) > > > > Changes in v2: > > - Introduce qemu_send_full() and use it > > > > include/qemu/sockets.h | 2 ++ > > tests/qtest/libqmp.c | 5 +++-- > > tests/qtest/libqtest.c | 4 ++-- > > util/osdep.c | 33 +++++++++++++++++++++++++++++++++ > > 4 files changed, 40 insertions(+), 4 deletions(-) > > > > diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h > > index 036745e586..adf2b21bd9 100644 > > --- a/include/qemu/sockets.h > > +++ b/include/qemu/sockets.h > > @@ -33,6 +33,8 @@ int qemu_socketpair(int domain, int type, int protocol, > > int sv[2]); > > #endif > > > > int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); > > +ssize_t qemu_send_full(int s, const void *buf, size_t count) > > + G_GNUC_WARN_UNUSED_RESULT; > > New global function prototypes in headers need documentation > comments, please.
In previous versions of this series I suggested we should be making libqmp/libqtest use the QIOChannelSocket API, instead of raw sockets code. The latter gives us portability already, and is what almost all of the rest of the codebase uses for sockets I/O. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|