On Sun, Jun 29, 2025 at 12:04:00AM -0400, Daniel Kahn Gillmor wrote:
> This uses the cached copy of LISTEN_FDNAMES to find the first file
> descriptorlabel with a matching label.
>
> Note that if two file descriptors are given the same label this will
> ignore all but the first.
>
> This is another step toward addressing
> https://gitlab.com/qemu-project/qemu/-/issues/3011
>
> Signed-off-by: Daniel Kahn Gillmor <[email protected]>
> ---
> include/qemu/systemd.h | 15 +++++++++++++++
> util/systemd.c | 35 +++++++++++++++++++++++++++++++++++
> 2 files changed, 50 insertions(+)
>
> +/*
> + * Check if socket activation indicates named file descriptor based on
> + * the colon-delimited LISTEN_FDNAMES. The "label" must not be NULL,
> + * and should be a simple text string that does not contain a colon,
> + * matching the FileDescriptorName= directive in systemd.socket(5)
> + *
> + * It is acceptable to ask for the empty string as a label.
> + *
> + * Returns -1 if no socket activation is in use, or if the label does
> + * not match any file descriptor. Otherwise, returns the lowest
> + * numeric value for a file descriptor matching the label exactly.
Per this description...
> #else /* !_WIN32 */
> unsigned int check_socket_activation(void)
> {
> return 0;
> }
> +unsigned int socket_activated_fd_by_label(const char *label)
> +{
> + return 0;
> +}
> #endif
this stub should probably return -1, not 0.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org