From patchwork Tue Jun 18 11:37:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Isaac X-Patchwork-Id: 14344 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 61E24170FF; Tue, 18 Jun 2019 12:39:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id DC7F3170FC for ; Tue, 18 Jun 2019 12:39:10 +0100 (BST) Received: from localhost ([::1]:55786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdCSD-00031M-DB for patchwork@mira.cbaines.net; Tue, 18 Jun 2019 07:39:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47299) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdCS7-00031E-QS for guix-patches@gnu.org; Tue, 18 Jun 2019 07:39:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdCS6-00042F-Kf for guix-patches@gnu.org; Tue, 18 Jun 2019 07:39:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hdCS6-00041Z-E6 for guix-patches@gnu.org; Tue, 18 Jun 2019 07:39:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hdCS6-00039R-8p for guix-patches@gnu.org; Tue, 18 Jun 2019 07:39:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#35895] [PATCH] linux-container: Remove networking service when network is shared with host. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 18 Jun 2019 11:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35895 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 35895-submit@debbugs.gnu.org id=B35895.156085788412043 (code B ref 35895); Tue, 18 Jun 2019 11:39:02 +0000 Received: (at 35895) by debbugs.gnu.org; 18 Jun 2019 11:38:04 +0000 Received: from localhost ([127.0.0.1]:43854 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdCRA-00038A-Ct for submit@debbugs.gnu.org; Tue, 18 Jun 2019 07:38:04 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:52708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hdCR6-00037i-Rq for 35895@debbugs.gnu.org; Tue, 18 Jun 2019 07:38:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pZuhrCBkJzbszyrPx/Nl6Ztces+5/3/ngvoly0tlOkk=; b=LFxxjvMMV0tSjQDDQm748vor6 mFHAh36/k1eUUAwOvWMI/Y/P54G9UqTG4AOG8NETJDRMfIyjHmOILEEPxhNc/meGixiXwUwSgZI0c i2R8pP8+iO+oaK0SXWUgwNYkCNexp8YoX23ji0nxCuTMQsLcudTKhiSebEHcHh31t8zXU=; Received: from [14.139.128.10] (helo=steel) by systemreboot.net with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1hdCR1-0000zo-DF; Tue, 18 Jun 2019 17:07:55 +0530 From: Arun Isaac In-Reply-To: <87a7el19nh.fsf@gnu.org> References: <20190525070113.5576-1-arunisaac@systemreboot.net> <20190525072030.7739-1-arunisaac@systemreboot.net> <8736l2iuao.fsf@cbaines.net> <20190603191031.7e751c2a@scratchpost.org> <87a7el19nh.fsf@gnu.org> Date: Tue, 18 Jun 2019 17:07:54 +0530 Message-ID: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 35895@debbugs.gnu.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches I've made the suggested changes. Please find attached an updated patch. From 4b50e35e3d2b8adea1e496e0336d23f35d0c9def Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sat, 25 May 2019 11:49:42 +0530 Subject: [PATCH] linux-container: Remove networking service when network is shared with host. * gnu/system/linux-container.scm (dummy-networking-shepherd-service): New procedure. (dummy-networking-service-type): New variable. (containerized-operating-system): If network is shared with host, replace static-networking-service-type with dummy-networking-service-type. --- gnu/system/linux-container.scm | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index c1e963d047..61248c62b9 100644 --- a/gnu/system/linux-container.scm +++ b/gnu/system/linux-container.scm @@ -30,6 +30,7 @@ #:use-module (gnu build linux-container) #:use-module (gnu services) #:use-module (gnu services base) + #:use-module (gnu services shepherd) #:use-module (gnu system) #:use-module (gnu system file-systems) #:export (system-container @@ -65,6 +66,16 @@ from OS that are needed on the bare metal and not in a container." files))) base))) +(define dummy-networking-service-type + (shepherd-service-type + 'dummy-networking + (const (shepherd-service + (documentation "Provide loopback and networking without actually +doing anything.") + (provision '(loopback networking)) + (start #~(const #t)))) + #f)) + (define* (containerized-operating-system os mappings #:key shared-network? @@ -96,7 +107,8 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS." agetty-service-type) ;; Remove nscd service if network is shared with the host. (if shared-network? - (list nscd-service-type) + (list nscd-service-type + static-networking-service-type) (list)))) (operating-system @@ -105,10 +117,17 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS." (essential-services (container-essential-services this-operating-system #:shared-network? shared-network?)) - (services (remove (lambda (service) - (memq (service-kind service) - useless-services)) - (operating-system-user-services os))) + (services (append (remove (lambda (service) + (memq (service-kind service) + useless-services)) + (operating-system-user-services os)) + ;; Many Guix services depend on a 'networking' shepherd + ;; service, so make sure to provide a dummy 'networking' + ;; service when we are sure that networking is already set up + ;; in the host and can be used. That prevents double setup. + (if shared-network? + (list (service dummy-networking-service-type)) + '()))) (file-systems (append (map mapping->fs (if shared-network? (append %network-file-mappings mappings) -- 2.22.0