From: Eric Blake <eblake@redhat.com>
To: "Richard W.M. Jones" <rjones@redhat.com>, pbonzini@redhat.com
Cc: stefanha@gmail.com, qemu-devel@nongnu.org, armbru@redhat.com,
dplotnikov@virtuozzo.com, rkagan@virtuozzo.com, den@openvz.org
Subject: Re: [Qemu-devel] [PATCH v5] qemu-nbd: Implement socket activation.
Date: Mon, 6 Feb 2017 13:04:52 -0600 [thread overview]
Message-ID: <21e1f16f-59f3-479c-a8f7-42cf5ada40b4@redhat.com> (raw)
In-Reply-To: <20170204100317.32425-2-rjones@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]
On 02/04/2017 04:03 AM, Richard W.M. Jones wrote:
> Socket activation (sometimes known as systemd socket activation)
> allows an Internet superserver to pass a pre-opened listening socket
> to the process, instead of having qemu-nbd open a socket itself. This
> is done via the LISTEN_FDS and LISTEN_PID environment variables, and a
> standard file descriptor range.
>
> This change partially implements socket activation for qemu-nbd. If
> the environment variables are set correctly, then socket activation
> will happen automatically, otherwise everything works as before. The
> limitation is that LISTEN_FDS must be 1.
>
> Signed-off-by: Richard W.M. Jones.
> ---
> +
> + /* So the file descriptors don't leak into child processes. */
> + for (i = 0; i < nr_fds; ++i) {
> + fd = FIRST_SOCKET_ACTIVATION_FD + i;
> + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
This is not the right way to do things (it risks clearing any other FD_
flags currently set on the fd, even though there aren't any such FD_
flags in common use). You HAVE to do F_GETFD before F_SETFD
(read-modify-write) for correct usage - and the best way to do that is
to use qemu_set_cloexec() from util/oslib-posix.c.
Except that qemu_set_cloexec() doesn't pay attention to errors...
> + /* If we cannot set FD_CLOEXEC then it probably means the file
> + * descriptor is invalid, so socket activation has gone wrong
> + * and we should exit.
> + */
> + error_report("Socket activation failed: "
> + "invalid file descriptor fd = %d: %m",
> + fd);
...while you use it for argument validation. Hmm.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2017-02-06 19:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-04 10:03 [Qemu-devel] [PATCH v5] qemu-nbd: Implement socket activation Richard W.M. Jones
2017-02-04 10:03 ` Richard W.M. Jones
2017-02-06 16:10 ` Paolo Bonzini
2017-02-06 16:29 ` Richard W.M. Jones
2017-02-06 16:49 ` Paolo Bonzini
2017-02-06 19:04 ` Eric Blake [this message]
2017-02-06 21:54 ` Paolo Bonzini
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=21e1f16f-59f3-479c-a8f7-42cf5ada40b4@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=dplotnikov@virtuozzo.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
--cc=rkagan@virtuozzo.com \
--cc=stefanha@gmail.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 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).