From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:48623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h42A3-0005qS-ND for guix-patches@gnu.org; Wed, 13 Mar 2019 07:35:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h42A2-0005yr-Mk for guix-patches@gnu.org; Wed, 13 Mar 2019 07:35:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55816) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h42A2-0005yi-GG for guix-patches@gnu.org; Wed, 13 Mar 2019 07:35:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h42A2-0005fc-C6 for guix-patches@gnu.org; Wed, 13 Mar 2019 07:35:02 -0400 Subject: [bug#28128] [PATCH 2/2] scripts: system: Support container network sharing. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20190313093610.1071-1-arunisaac@systemreboot.net> <20190313093610.1071-3-arunisaac@systemreboot.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Arun Isaac Cc: 28128@debbugs.gnu.org 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.