From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 2/6] isolation, conf: Set c->fd_tap from eary parse of --fd
Date: Thu, 16 Jul 2026 15:12:44 +1000 [thread overview]
Message-ID: <alhoQU6RR2jiBcdh@zatzit> (raw)
In-Reply-To: <20260715091234.603c7963@elisabeth>
[-- Attachment #1: Type: text/plain, Size: 2828 bytes --]
On Wed, Jul 15, 2026 at 09:12:35AM +0200, Stefano Brivio wrote:
> On Tue, 14 Jul 2026 19:29:22 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > We parse --fd twice: once in isolate_initial() just to avoid clobbering
> > the passed in fd. Then we parse it "for real" in conf(), to set c->fd_tap
> > and other configuration variables.
> >
> > Change this, so that we return the value parsed early from
> > isolate_initial() and set c->fd_tap from that. This doesn't accomplish
> > much immediately, but will make some further cleanups possible.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > conf.c | 2 +-
> > isolation.c | 6 +++++-
> > isolation.h | 2 +-
> > passt.c | 2 +-
> > 4 files changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/conf.c b/conf.c
> > index 6d83daef..41c9d557 100644
> > --- a/conf.c
> > +++ b/conf.c
> > @@ -1593,7 +1593,7 @@ void conf(struct ctx *c, int argc, char **argv)
> > c->fd_control_listen = c->fd_control = -1;
> > break;
> > case 'F':
> > - c->fd_tap = conf_tap_fd(optarg);
> > + /* --fd was parsed early and c->fd_tap set in main() */
> > c->one_off = true;
> > *c->sock_path = 0;
> > break;
> > diff --git a/isolation.c b/isolation.c
> > index 07b281bb..4bb79e34 100644
> > --- a/isolation.c
> > +++ b/isolation.c
> > @@ -203,8 +203,10 @@ static int move_root(void)
> > * - close all open files except for standard streams and the one from --fd
> > * Mustn't:
> > * - remove filesystem access (we need to access files during setup)
> > + *
> > + * Return: fd number from --fd, or -1 if not specified
>
> I think this is a rather weird value to return for a function that's
> called isolate_initial().
Agreed, but there are reasons..
> Are patches 1/2 and 2/2 really needed for the
> rest of the series? I don't quite see the connection.
1) (minor) The new semantics of conf_tap_fd() introduced in 3/6 work
better (IMO) for its use in close_open_files(), but don't work for
its reuse during the "main" arg parse. Removing that second parse
avoids the problem.
2) (major) 4/6 significantly simplifies the close_range() logic, but
it involves *moving* the tap descriptor given with --fd (using
dup2(2). That means if we parsed it again, it would now be wrong.
I think the weirdness would also be mitigated, if close_open_files()
became isolate_fds(), and was called directly from main() rather than
via isolate_initial().
>
> I'm still reviewing the rest of the series.
>
> --
> Stefano
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-07-16 5:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 9:29 [PATCH 0/6] Fix bug 215 and some related issues with fd handling David Gibson
2026-07-14 9:29 ` [PATCH 1/6] isolation, util: Fold close_open_files() into isolate_initial() David Gibson
2026-07-15 7:12 ` Stefano Brivio
2026-07-16 5:06 ` David Gibson
2026-07-14 9:29 ` [PATCH 2/6] isolation, conf: Set c->fd_tap from eary parse of --fd David Gibson
2026-07-15 7:12 ` Stefano Brivio
2026-07-16 5:12 ` David Gibson [this message]
2026-07-14 9:29 ` [PATCH 3/6] conf: Make conf_tap_fd() operate more like conf_mode() David Gibson
2026-07-14 9:29 ` [PATCH 4/6] isolation: Move --fd descriptor to a number of our choosing David Gibson
2026-07-14 9:29 ` [PATCH 5/6] main: Ensure fds 0-2 are populated David Gibson
2026-07-14 9:29 ` [PATCH 6/6] passt: *Always* close pidfile_fd, not just when daemonizing David Gibson
2026-07-15 16:39 ` [PATCH 0/6] Fix bug 215 and some related issues with fd handling Stefano Brivio
2026-07-16 5:25 ` David Gibson
2026-07-16 7:22 ` Stefano Brivio
2026-07-16 7:49 ` David Gibson
2026-07-16 8:02 ` Stefano Brivio
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=alhoQU6RR2jiBcdh@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
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 IMAP folder(s).