From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: Richard Henderson <richard.henderson@linaro.org>,
QEMU <qemu-devel@nongnu.org>, Michael Roth <michael.roth@amd.com>
Subject: Re: [PATCH v2 12/26] qga: replace pipe() with g_unix_open_pipe(CLOEXEC)
Date: Tue, 3 May 2022 12:22:55 +0100 [thread overview]
Message-ID: <YnEQhSZeVsAVuR4R@redhat.com> (raw)
In-Reply-To: <CAJ+F1CLE9GKZ5of1xVTGs3Khf6KSC+--FB9Z4-JWuVEVYZqDCg@mail.gmail.com>
On Wed, Apr 27, 2022 at 12:24:44PM +0400, Marc-André Lureau wrote:
> Hi
>
> On Wed, Apr 27, 2022 at 5:08 AM Richard Henderson <
> richard.henderson@linaro.org> wrote:
>
> > On 4/26/22 02:27, marcandre.lureau@redhat.com wrote:
> > > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > >
> > > Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > > qga/commands-posix.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> > > index 77f4672ca2c9..094487c2c395 100644
> > > --- a/qga/commands-posix.c
> > > +++ b/qga/commands-posix.c
> > > @@ -2529,7 +2529,7 @@ void qmp_guest_set_user_password(const char
> > *username,
> > > goto out;
> > > }
> > >
> > > - if (pipe(datafd) < 0) {
> > > + if (!g_unix_open_pipe(datafd, FD_CLOEXEC, NULL)) {
> > > error_setg(errp, "cannot create pipe FDs");
> > > goto out;
> > > }
> >
> > This looks wrong, since the next thing that happens is fork+execl.
> >
> >
> Before exec(), it does
> close(datafd[1]);
> dup2(datafd[0], 0);
>
> 0, the newfd, does not share file descriptor flags (the close-on-exec flag).
>
> I did a quick test, and it seems to be fine.
The 'dup' man page says
The two file descriptors do not share file descriptor flags
(the close-on-exec flag). The close-on-exec flag (FD_CLOEXEC;
see fcntl(2)) for the duplicate descriptor is off.
so we're fine in this respect. You could need to use dup3 to explicitly
turn on FD_CLOEXEC on the duplicate, so
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 :|
next prev parent reply other threads:[~2022-05-03 11:27 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 9:26 [PATCH v2 00/26] Misc cleanups marcandre.lureau
2022-04-26 9:26 ` [PATCH v2 01/26] Use QEMU_SANITIZE_THREAD marcandre.lureau
2022-04-26 20:43 ` Richard Henderson
2022-04-27 7:59 ` Marc-André Lureau
2022-04-26 9:26 ` [PATCH v2 02/26] Use QEMU_SANITIZE_ADDRESS marcandre.lureau
2022-04-26 20:46 ` Richard Henderson
2022-04-27 9:36 ` Thomas Huth
2022-04-26 9:26 ` [PATCH v2 03/26] include: move qemu_*_exec_dir() to cutils marcandre.lureau
2022-04-26 9:26 ` [PATCH v2 04/26] util/win32: simplify qemu_get_local_state_dir() marcandre.lureau
2022-04-26 9:26 ` [PATCH v2 05/26] tests: move libqtest.h back under qtest/ marcandre.lureau
2022-04-26 10:30 ` Stefan Berger
2022-05-30 14:41 ` Juan Quintela
2022-04-26 9:26 ` [PATCH v2 06/26] libqtest: split QMP part in libqmp marcandre.lureau
2022-04-26 9:26 ` [PATCH v2 07/26] tests: make libqmp buildable for win32 marcandre.lureau
2022-04-26 9:32 ` Thomas Huth
2022-04-26 10:25 ` Marc-André Lureau
2022-04-26 10:29 ` Thomas Huth
2022-04-26 9:26 ` [PATCH v2 08/26] Use g_unix_set_fd_nonblocking() marcandre.lureau
2022-04-27 1:00 ` Richard Henderson
2022-04-26 9:26 ` [PATCH v2 09/26] block: move fcntl_setfl() marcandre.lureau
2022-04-27 1:00 ` Richard Henderson
2022-04-26 9:26 ` [PATCH v2 10/26] Replace qemu_pipe() with g_unix_open_pipe() marcandre.lureau
2022-04-27 1:06 ` Richard Henderson
2022-04-26 9:27 ` [PATCH v2 11/26] util: replace pipe()+cloexec " marcandre.lureau
2022-04-27 1:06 ` Richard Henderson
2022-04-26 9:27 ` [PATCH v2 12/26] qga: replace pipe() with g_unix_open_pipe(CLOEXEC) marcandre.lureau
2022-04-27 1:08 ` Richard Henderson
2022-04-27 8:24 ` Marc-André Lureau
2022-05-03 11:22 ` Daniel P. Berrangé [this message]
2022-04-26 9:27 ` [PATCH v2 13/26] tests: " marcandre.lureau
2022-05-03 10:11 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 14/26] os-posix: replace pipe()+cloexec " marcandre.lureau
2022-04-27 1:11 ` Richard Henderson
2022-04-26 9:27 ` [PATCH v2 15/26] virtiofsd: replace pipe() " marcandre.lureau
2022-05-03 10:16 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 16/26] io: " marcandre.lureau
2022-05-03 10:29 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 17/26] Replace fcntl(0_NONBLOCK) with g_unix_set_fd_nonblocking() marcandre.lureau
2022-04-27 1:15 ` Richard Henderson
2022-04-27 9:08 ` Marc-André Lureau
2022-04-26 9:27 ` [PATCH v2 18/26] io: make qio_channel_command_new_pid() static marcandre.lureau
2022-04-27 1:15 ` Richard Henderson
2022-04-26 9:27 ` [PATCH v2 19/26] chardev: replace qemu_set_nonblock() marcandre.lureau
2022-05-03 10:32 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 20/26] io: replace qemu_set{_non}block() marcandre.lureau
2022-05-03 10:33 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 21/26] qga: replace qemu_set_nonblock() marcandre.lureau
2022-05-03 10:35 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 22/26] hw: " marcandre.lureau
2022-05-03 10:38 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 23/26] ui: " marcandre.lureau
2022-05-03 10:41 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 24/26] net: " marcandre.lureau
2022-05-03 10:42 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 25/26] tests: " marcandre.lureau
2022-04-27 9:41 ` Thomas Huth
2022-04-27 10:33 ` Marc-André Lureau
2022-04-27 11:15 ` Thomas Huth
2022-05-03 10:44 ` Daniel P. Berrangé
2022-04-26 9:27 ` [PATCH v2 26/26] util: rename qemu_*block() socket functions marcandre.lureau
2022-04-26 10:28 ` Marc-André Lureau
2022-04-26 14:33 ` Stefan Hajnoczi
2022-04-27 10:39 ` Marc-André Lureau
2022-05-02 7:45 ` [PATCH v2 00/26] Misc cleanups Marc-André Lureau
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=YnEQhSZeVsAVuR4R@redhat.com \
--to=berrange@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=michael.roth@amd.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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).