All of lore.kernel.org
 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,
	Paolo Bonzini <pbonzini@redhat.com>, Stefan Weil <sw@weilnetz.de>
Subject: Re: [PATCH v2 3/8] util: add qemu_set_blocking() function
Date: Fri, 12 Sep 2025 17:51:13 +0100	[thread overview]
Message-ID: <aMRPgVbdZWaG8PXS@redhat.com> (raw)
In-Reply-To: <20250911092007.1370002-4-vsementsov@yandex-team.ru>

On Thu, Sep 11, 2025 at 12:20:01PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> In generic code we have qio_channel_set_blocking(), which takes
> bool parameter, and qemu_file_set_blocking(), which as well takes
> bool parameter.
> 
> At lower fd-layer we have a mess of functions:
> 
> - enough direct calls to Unix-specific g_unix_set_fd_nonblocking()
> (of course, all calls are out of Windows-compatible code), which
> is glib specific with GError, which we can't use, and have to
> handle error-reporting by hand after the call.
> 
> and several platform-agnostic qemu_* helpers:
> 
> - qemu_socket_set_nonblock(), which asserts success for posix (still,
>   in most cases we can handle the error in better way) and ignores
>   error for win32 realization
> 
> - qemu_socket_try_set_nonblock(), providing and error, but not errp,
> so we have to handle it after the call
> 
> - qemu_socket_set_block(), which simply ignores an error
> 
> Note, that *_socket_* word in original API, which we are going
> to substitute was intended, because Windows support these operations
> only for sockets. What leads to solution of dropping it again?
> 
> 1. Having a QEMU-native wrapper with errp parameter
> for g_unix_set_fd_nonblocking() for non-socket fds worth doing,
> at least to unify error handling.
> 
> 2. So, if try to keep _socket_ vs _file_ words, we'll have two
> actually duplicated functions for Linux, which actually will
> be executed successfully on any (good enough) fds, and nothing
> prevent using them improperly except for the name. That doesn't
> look good.
> 
> 3. Naming helped us in the world where we crash on errors or
> ignore them. Now, with errp parameter, callers are intended to
> proper error checking. And for places where we really OK with
> crash-on-error semantics (like tests), we have an explicit
> &error_abort.
> 
> So, this commit starts a series, which will effectively revert
> commit ff5927baa7ffb9 "util: rename qemu_*block() socket functions"
> (which in turn was reverting f9e8cacc5557e43
> "oslib-posix: rename socket_set_nonblock() to qemu_set_nonblock()",
> so that's a long story).
> Now we don't simply rename, instead we provide the new API and
> update all the callers.
> 
> This commit only introduces a new fd-layer wrapper. Next commits
> will replace old API calls with it, and finally remove old API.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  include/qemu/osdep.h |  1 +
>  util/oslib-posix.c   | 15 +++++++++++++++
>  util/oslib-win32.c   | 18 ++++++++++++++++++
>  3 files changed, 34 insertions(+)

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-12 16:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11  9:19 [PATCH v2 0/8] io: deal with blocking/non-blocking fds Vladimir Sementsov-Ogievskiy
2025-09-11  9:19 ` [PATCH v2 1/8] char-socket: tcp_chr_recv(): drop extra _set_(block, cloexec) Vladimir Sementsov-Ogievskiy
2025-09-12 16:49   ` [PATCH v2 1/8] char-socket: tcp_chr_recv(): drop extra _set_(block,cloexec) Daniel P. Berrangé
2025-09-11  9:20 ` [PATCH v2 2/8] char-socket: tcp_chr_recv(): add comment Vladimir Sementsov-Ogievskiy
2025-09-12 16:50   ` Daniel P. Berrangé
2025-09-11  9:20 ` [PATCH v2 3/8] util: add qemu_set_blocking() function Vladimir Sementsov-Ogievskiy
2025-09-12 16:51   ` Daniel P. Berrangé [this message]
2025-09-11  9:20 ` [PATCH v2 4/8] util: drop qemu_socket_set_nonblock() Vladimir Sementsov-Ogievskiy
2025-09-12 16:59   ` Daniel P. Berrangé
2025-09-15  8:07     ` Vladimir Sementsov-Ogievskiy
2025-09-15  8:09     ` Vladimir Sementsov-Ogievskiy
2025-09-11  9:20 ` [PATCH v2 5/8] util: drop qemu_socket_try_set_nonblock() Vladimir Sementsov-Ogievskiy
2025-09-12 17:00   ` Daniel P. Berrangé
2025-09-11  9:20 ` [PATCH v2 6/8] io/channel-socket: rework qio_channel_socket_copy_fds() Vladimir Sementsov-Ogievskiy
2025-09-12 17:05   ` Daniel P. Berrangé
2025-09-15  8:47     ` Vladimir Sementsov-Ogievskiy
2025-09-11  9:20 ` [PATCH v2 7/8] util: drop qemu_socket_set_block() Vladimir Sementsov-Ogievskiy
2025-09-12 17:06   ` Daniel P. Berrangé
2025-09-11  9:20 ` [PATCH v2 8/8] use qemu_set_blocking instead of g_unix_set_fd_nonblocking Vladimir Sementsov-Ogievskiy
2025-09-12 17:11   ` Daniel P. Berrangé
2025-09-15 10:04     ` Vladimir Sementsov-Ogievskiy
2025-09-11  9:22 ` [PATCH v2 0/8] 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=aMRPgVbdZWaG8PXS@redhat.com \
    --to=berrange@redhat.com \
    --cc=leiyang@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.