From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 13 07:34:36 2019 Received: (at 28128) by debbugs.gnu.org; 13 Mar 2019 11:34:36 +0000 Received: from localhost ([127.0.0.1]:41127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h429c-0005es-2d for submit@debbugs.gnu.org; Wed, 13 Mar 2019 07:34:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34172) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h429a-0005ee-Nf for 28128@debbugs.gnu.org; Wed, 13 Mar 2019 07:34:35 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h429U-0005jG-Q9; Wed, 13 Mar 2019 07:34:28 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56618 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h429U-0006Qu-8A; Wed, 13 Mar 2019 07:34:28 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Arun Isaac Subject: Re: [PATCH 2/2] scripts: system: Support container network sharing. References: <20190313093610.1071-1-arunisaac@systemreboot.net> <20190313093610.1071-3-arunisaac@systemreboot.net> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 23 =?utf-8?Q?Vent=C3=B4se?= an 227 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 13 Mar 2019 12:34:26 +0100 In-Reply-To: <20190313093610.1071-3-arunisaac@systemreboot.net> (Arun Isaac's message of "Wed, 13 Mar 2019 15:06:10 +0530") Message-ID: <87va0n80u5.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 28128 Cc: mail@cbaines.net, 28128@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello! Some comments below. Arun Isaac skribis: > * gnu/services.scm (shared-network-service-type): New variable. > * gnu/services/base.scm (%base-services): Add shared-network-service. > * gnu/system.scm (essential-services): If shared-network-service exists, > extend it to add /etc/services, /etc/nsswitch.conf and /etc/hosts. > (operating-system-etc-service): Do not add /etc/services, /etc/nsswitch.c= onf > and /etc/hosts. > * gnu/system/linux-container.scm (container-script): Support returning a > container script that shares the host network. > * guix/scripts/system.scm (system-derivation-for-action, perform-action):= Add > #:container-shared-network? argument. > (show-help): Add "-N, --network" help information. > (%options): Add network option. > (process-action): Call perform-action with #:container-shared-network?. > > Co-authored-by: Christopher Baines [...] > +(define shared-network-service-type > + (service-type (name 'shared-network) > + (extensions (list (service-extension etc-service-type id= entity))) > + (compose concatenate) > + (extend append) > + (default-value '()))) I=E2=80=99d encourage you to add a =E2=80=98description=E2=80=99 field as w= ell. :-) > --- a/gnu/system.scm > +++ b/gnu/system.scm > @@ -5,6 +5,7 @@ > ;;; Copyright =C2=A9 2016 Chris Marusich > ;;; Copyright =C2=A9 2017 Mathieu Othacehe > ;;; Copyright =C2=A9 2019 Meiyo Peng > +;;; Copyright =C2=A9 2019 Arun Isaac > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -501,7 +502,21 @@ a container or that of a \"bare metal\" system." > (list %containerized-shepherd-service) > (list %linux-bare-metal-service > (service firmware-service-type > - (operating-system-firmware os)))))= ))) > + (operating-system-firmware os)))) > + (if (find (lambda (service) > + (eq? (service-type-name (service-kind ser= vice)) > + 'shared-network)) > + (operating-system-user-services os)) > + (let ((nsswitch (plain-file "nsswitch.conf" > + (name-service-switch-= >string > + (operating-system-na= me-service-switch os))))) > + (list (simple-service 'shared-network-extension > + shared-network-service-ty= pe > + `(("services" ,(file-appe= nd net-base "/etc/services")) > + ("nsswitch.conf" ,#~#$n= sswitch) > + ("hosts" ,#~#$(or (oper= ating-system-hosts-file os) > + (defa= ult-/etc/hosts (operating-system-host-name os)))))))) > + (list)))))) A couple of things: 1. =E2=80=98service-type-name=E2=80=99 exists for debugging purposes, and= I think we shouldn=E2=80=99t rely on it at all in our code. Instead, we should compare service types by identity, as in: (eq? (service-kind service) foo-service-type) 2. The notion of =E2=80=9Cshared network=E2=80=9D is very much a containe= r (or VM) thing, so somehow it still doesn=E2=80=99t feel right to me that (gnu system) has to be aware of these special cases. I think the =E2=80=98host-database-service-type=E2=80=99 wouldn=E2=80=99t h= ave this problem, but maybe it has other issues. I guess this needs more experimentation, sorry for not coming up with clearer ideas! Ludo=E2=80=99.