All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>,
	 andrey.drobyshev@virtuozzo.com
Cc: svt-core@virtuozzo.com, den@openvz.org
Subject: Re: [PATCH hci-dev] monitor/qmp: cleanup SocketChardev listener sources early to avoid fd handling race #VSTOR-155186
Date: Mon, 16 Nov 2026 13:37:47 +0000	[thread overview]
Message-ID: <010701a1e494016a-74195a25-611f-4fa7-8bd0-b2d6e7948939-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261116133056.1046875-1-andrey.zhadchenko@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] chardev: misleading name and no docs for chr_listener_cleanup
  hook
--

commit 5c8cab67961662e98b03d6e5525ecf5fdb9c1a1e
Author: Jie Song <songjie_yewu@cmss.chinamobile.com>

monitor/qmp: cleanup SocketChardev listener sources early to avoid fd handling race #VSTOR-155186

This commit adds an optional chr_listener_cleanup hook to ChardevClass. The socket chardev implements it by dropping the listener's accept handler and IO sources. monitor_init_qmp() calls the hook through a new helper, remove_listener_fd_in_watch(), before the IOThread takes over the QMP fd.

> diff --git a/chardev/char-io.c b/chardev/char-io.c
> index d9b11f335ffb6..0e5ba316ed9fb 100644
> --- a/chardev/char-io.c
> +++ b/chardev/char-io.c
> @@ -187,3 +187,11 @@ int io_channel_send(QIOChannel *ioc, const void *buf, size_t len)
>  {
>      return io_channel_send_full(ioc, buf, len, NULL, 0);
>  }
> +
> +void remove_listener_fd_in_watch(Chardev *chr)
> +{
> +    ChardevClass *cc = CHARDEV_GET_CLASS(chr);
> +    if (cc->chr_listener_cleanup) {
> +        cc->chr_listener_cleanup(chr);
> +    }
> +}

[Severity: Low]
This isn't a bug, but the name is misleading. Sitting next to remove_fd_in_watch(), remove_listener_fd_in_watch() suggests it removes an fd watch. It actually calls the backend hook, which for sockets detaches the listener's accept handler via qio_net_listener_set_client_func_full() with a NULL func. Could the helper get a name or a comment that says so?

[ ... ]

> diff --git a/include/chardev/char.h b/include/chardev/char.h
> index 968766fd5d5ee..62cfdc2d3d765 100644
> --- a/include/chardev/char.h
> +++ b/include/chardev/char.h
> @@ -313,6 +313,8 @@ struct ChardevClass {
>  
>      /* handle various events */
>      void (*chr_be_event)(Chardev *s, QEMUChrEvent event);
> +
> +    void (*chr_listener_cleanup)(Chardev *chr);
>  };

The new chr_listener_cleanup field has no comment, unlike its neighbouring hooks. Could it document that the hook is optional, which thread may call it, and that the backend must re-arm the listener later? For the socket backend, that re-arm happens in tcp_chr_update_read_handler() when the state is TCP_CHARDEV_STATE_DISCONNECTED.

Also, the commit message says the IOThread only removes the main thread's fd watch when it reaches qio_net_listener_set_client_func_full(). That is imprecise. The function destroys the old listener sources and creates new ones in the target context.

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261116133056.1046875-1-andrey.zhadchenko@virtuozzo.com?part=1

  reply	other threads:[~2026-11-16 13:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 13:30 Andrey Zhadchenko
2026-11-16 13:37 ` no-reply [this message]
2026-11-16 13:50 ` Denis V. Lunev
2026-11-16 13:55 ` Andrey Drobyshev

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=010701a1e494016a-74195a25-611f-4fa7-8bd0-b2d6e7948939-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=andrey.zhadchenko@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=svt-core@virtuozzo.com \
    /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.