all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christopher Baines <mail@cbaines.net>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 34638@debbugs.gnu.org
Subject: [bug#34638] [PATCH 2/4] linux-container: Add 'start-child-in-container'.
Date: Fri, 19 Apr 2019 15:16:40 +0100	[thread overview]
Message-ID: <87pnpit707.fsf@cbaines.net> (raw)
In-Reply-To: <87lg1hiam0.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2627 bytes --]


Ludovic Courtès <ludo@gnu.org> writes:

> Hello!
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> This new procedure is similar to open-pipe* in (ice-9 popen), but using
>> run-container from (gnu build linux-container).
>>
>> * gnu/build/linux-container.scm (start-child-in-container): New procedure.
>
> [...]
>
>  +(define* (start-child-in-container command
>> +                                   #:key read? write?
>> +                                   (root 'temporary)
>> +                                   (mounts '())
>> +                                   (namespaces %namespaces)
>> +                                   (host-uids 1)
>> +                                   (extra-environment-variables '()))
>
> We could even call that ‘open-pipe/container’, for clarity.

I've made some changes (see below) that move this a little further away
from open-pipe in terms of behaviour now.

>> +  (define (with-root-directory f)
>> +    (if (eq? root 'temporary)
>> +        (call-with-temporary-directory f)
>> +        (f root)))
>> +
>> +  ;; (ice-9 popen) internals
>> +  (define make-rw-port (@@ (ice-9 popen) make-rw-port))
>> +  (define pipe-guardian (@@ (ice-9 popen) pipe-guardian))
>> +  (define make-pipe-info (@@ (ice-9 popen) make-pipe-info))
>
> So this is the funky part.  ;-)
>
> What if we did something like:
>
>   (call-with-container mounts
>     (lambda ()
>       ;; Somehow act as a proxy between the output process
>       ;; and the one spawned by ‘open-pipe*’.
>       (open-pipe* …)))
>
> ?  Would that work?
>
> That’s create an extra process, but if it works, it’s probably safer and
> a lesser maintenance burden.
>
> Now, I think that Guile should expose some of the popen internals
> somehow so we can do things like you did, but that’s another story.

I'm hesitant to try that, as the additional process in the middle seems
a bit awkward to me.

I've made another pass over the code, removed all the uses of (ice-9
popen) internals, and sent another set of patches. For the make-rw-port
function, I just copied that over. The pipe-guardian isn't being used
now, and instead of returning a <pipe-info> record, the port and pid are
returned instead. This works with the inferior use case, as the close
function provided to port->inferior does the right thing, closing the
port and then waiting for the child process to exit, just like popen.

I'm still more interested in getting something working than it being
perfect in any particular way, but let me know what you think.

Thanks,

Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 962 bytes --]

  reply	other threads:[~2019-04-19 14:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-24 16:12 [bug#34638] [PATCH 0/4] Isolated inferiors Christopher Baines
2019-02-24 16:18 ` [bug#34638] [PATCH 1/4] utils: Add #:base-directory to call-with-temporary-directory Christopher Baines
2019-02-24 16:18   ` [bug#34638] [PATCH 2/4] linux-container: Add 'start-child-in-container' Christopher Baines
2019-03-14 18:17     ` Ludovic Courtès
2019-04-19 14:16       ` Christopher Baines [this message]
2019-02-24 16:18   ` [bug#34638] [PATCH 3/4] inferior: Add a shared-directory field to <inferior> Christopher Baines
2019-02-24 16:18   ` [bug#34638] [PATCH 4/4] inferior: Add 'open-inferior/container' Christopher Baines
2019-03-14 19:35 ` [bug#34638] [PATCH 0/4] Isolated inferiors Ludovic Courtès
2019-04-19 14:04 ` [bug#34638] [PATCH v2 1/4] utils: Add #:base-directory to call-with-temporary-directory Christopher Baines
2019-04-19 14:04   ` [bug#34638] [PATCH v2 2/4] linux-container: Add 'start-child-in-container' Christopher Baines
2020-03-26  9:28     ` Ludovic Courtès
2020-03-28 11:26       ` Christopher Baines
2020-03-28 12:20         ` Ludovic Courtès
2019-04-19 14:04   ` [bug#34638] [PATCH v2 3/4] inferior: Add a shared-directory field to <inferior> Christopher Baines
2020-03-26  9:30     ` Ludovic Courtès
2019-04-19 14:04   ` [bug#34638] [PATCH v2 4/4] inferior: Add 'open-inferior/container' Christopher Baines
2020-03-26  9:32     ` Ludovic Courtès
2020-03-26  9:22   ` [bug#34638] [PATCH v2 1/4] utils: Add #:base-directory to call-with-temporary-directory Ludovic Courtès

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=87pnpit707.fsf@cbaines.net \
    --to=mail@cbaines.net \
    --cc=34638@debbugs.gnu.org \
    --cc=ludo@gnu.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

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.