qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: qemu-devel@nongnu.org, peterx@redhat.com, qemu-block@nongnu.org,
	leiyang@redhat.com, marcandre.lureau@redhat.com,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Stefano Garzarella <sgarzare@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Michael Roth <michael.roth@amd.com>,
	Kostiantyn Kostiuk <kkostiuk@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>,
	Coiby Xu <Coiby.Xu@gmail.com>
Subject: Re: [PATCH v5 06/13] util: drop qemu_socket_set_nonblock()
Date: Tue, 16 Sep 2025 16:47:48 +0100	[thread overview]
Message-ID: <aMmGpFB86YCXquxH@redhat.com> (raw)
In-Reply-To: <20250916131403.368343-7-vsementsov@yandex-team.ru>

On Tue, Sep 16, 2025 at 04:13:55PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Use common qemu_set_blocking() instead.
> 
> Note that pre-patch the behavior of Win32 and Linux realizations
> are inconsistent: we ignore failure for Win32, and assert success
> for Linux.
> 
> How do we convert the callers?
> 
> 1. Most of callers call qemu_socket_set_nonblock() on a
> freshly created socket fd, in conditions when we may simply
> report an error. Seems correct switching to error handling
> both for Windows (pre-patch error is ignored) and Linux
> (pre-patch we assert success). Anyway, we normally don't
> expect errors in these cases.
> 
> Still in tests let's use &error_abort for simplicity.
> 
> What are exclusions?
> 
> 2. hw/virtio/vhost-user.c - we are inside #ifdef CONFIG_LINUX,
> so no damage in switching to error handling from assertion.
> 
> 3. io/channel-socket.c: here we convert both old calls to
> qemu_socket_set_nonblock() and qemu_socket_set_block() to
> one new call. Pre-patch we assert success for Linux in
> qemu_socket_set_nonblock(), and ignore all other errors here.
> So, for Windows switch is a bit dangerous: we may get
> new errors or crashes(when error_abort is passed) in
> cases where we have silently ignored the error before
> (was it correct in all such cases, if they were?) Still,
> there is no other way to stricter API than take
> this risk.
> 
> 4. util/vhost-user-server - compiled only for Linux (see
> util/meson.build), so we are safe, switching from assertion to
> &error_abort.
> 
> Note: In qga/channel-posix.c we use g_warning(), where g_printerr()
> would actually be a better choice. Still let's for now follow
> common style of qga, where g_warning() is commonly used to print
> such messages, and no call to g_printerr(). Converting everything
> to use g_printerr() should better be another series.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  contrib/ivshmem-server/ivshmem-server.c |  9 ++++++++-
>  hw/hyperv/syndbg.c                      |  4 +++-
>  hw/virtio/vhost-user.c                  |  5 ++++-
>  include/qemu/sockets.h                  |  1 -
>  io/channel-socket.c                     |  7 +++----
>  net/dgram.c                             | 16 +++++++++++++---
>  net/l2tpv3.c                            |  5 +++--
>  net/socket.c                            | 20 ++++++++++++++++----
>  qga/channel-posix.c                     |  7 ++++++-
>  tests/unit/socket-helpers.c             |  4 +++-
>  tests/unit/test-crypto-tlssession.c     |  8 ++++----
>  util/oslib-posix.c                      |  7 -------
>  util/oslib-win32.c                      |  5 -----
>  util/vhost-user-server.c                |  6 ++++--
>  14 files changed, 67 insertions(+), 37 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


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



  reply	other threads:[~2025-09-16 15:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16 13:13 [PATCH v5 00/13] io: deal with blocking/non-blocking fds Vladimir Sementsov-Ogievskiy
2025-09-16 13:13 ` [PATCH v5 01/13] char-socket: tcp_chr_recv(): drop extra _set_(block, cloexec) Vladimir Sementsov-Ogievskiy
2025-09-16 13:13 ` [PATCH v5 02/13] char-socket: tcp_chr_recv(): add comment Vladimir Sementsov-Ogievskiy
2025-09-16 13:13 ` [PATCH v5 03/13] util: add qemu_set_blocking() function Vladimir Sementsov-Ogievskiy
2025-09-16 13:13 ` [PATCH v5 04/13] handle result of qio_channel_set_blocking() Vladimir Sementsov-Ogievskiy
2025-09-16 13:57   ` Peter Xu
2025-09-16 14:18     ` Vladimir Sementsov-Ogievskiy
2025-09-19 10:22   ` Daniel P. Berrangé
2025-09-16 13:13 ` [PATCH v5 05/13] migration: qemu_file_set_blocking(): add errp parameter Vladimir Sementsov-Ogievskiy
2025-09-16 14:02   ` Peter Xu
2025-09-16 15:38   ` Daniel P. Berrangé
2025-09-16 15:43   ` Daniel P. Berrangé
2025-09-16 13:13 ` [PATCH v5 06/13] util: drop qemu_socket_set_nonblock() Vladimir Sementsov-Ogievskiy
2025-09-16 15:47   ` Daniel P. Berrangé [this message]
2025-09-16 13:13 ` [PATCH v5 07/13] util: drop qemu_socket_try_set_nonblock() Vladimir Sementsov-Ogievskiy
2025-09-16 13:13 ` [PATCH v5 08/13] io/channel-socket: rework qio_channel_socket_copy_fds() Vladimir Sementsov-Ogievskiy
2025-09-16 13:13 ` [PATCH v5 09/13] util: drop qemu_socket_set_block() Vladimir Sementsov-Ogievskiy
2025-09-16 13:13 ` [PATCH v5 10/13] use qemu_set_blocking instead of g_unix_set_fd_nonblocking Vladimir Sementsov-Ogievskiy
2025-09-19 10:24   ` Daniel P. Berrangé
2025-09-16 13:14 ` [PATCH v5 11/13] chardev: qemu_chr_open_fd(): add errp Vladimir Sementsov-Ogievskiy
2025-09-16 13:14 ` [PATCH v5 12/13] chardev: close an fd on failure path Vladimir Sementsov-Ogievskiy
2025-09-16 13:14 ` [PATCH v5 13/13] util/vhost-user-server: vu_message_read(): improve error handling Vladimir Sementsov-Ogievskiy
2025-09-16 15:50   ` Daniel P. Berrangé
2025-09-17 10:13     ` Vladimir Sementsov-Ogievskiy
2025-09-19 10:27       ` Daniel P. Berrangé
2025-09-19 10:44         ` Vladimir Sementsov-Ogievskiy
2025-09-16 13:15 ` [PATCH v5 00/13] io: deal with blocking/non-blocking fds Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aMmGpFB86YCXquxH@redhat.com \
    --to=berrange@redhat.com \
    --cc=Coiby.Xu@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=kkostiuk@redhat.com \
    --cc=leiyang@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=sw@weilnetz.de \
    --cc=vsementsov@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).