From patchwork Sun Jun 9 20:35:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Isaac X-Patchwork-Id: 14274 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 CDAE617045; Sun, 9 Jun 2019 21:36:15 +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 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 8A74E16F88 for ; Sun, 9 Jun 2019 21:36:15 +0100 (BST) Received: from localhost ([::1]:38308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ha4Y2-0002H4-TJ for patchwork@mira.cbaines.net; Sun, 09 Jun 2019 16:36:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46524) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1ha4Xy-0002Gm-8d for guix-patches@gnu.org; Sun, 09 Jun 2019 16:36:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ha4Xx-0007kK-4m for guix-patches@gnu.org; Sun, 09 Jun 2019 16:36:10 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41924) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ha4Xq-0007fA-LV for guix-patches@gnu.org; Sun, 09 Jun 2019 16:36:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ha4Xq-0002vR-F7 for guix-patches@gnu.org; Sun, 09 Jun 2019 16:36: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: Sun, 09 Jun 2019 20:36: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: Danny Milosavljevic , Christopher Baines Received: via spool by 35895-submit@debbugs.gnu.org id=B35895.156011254611208 (code B ref 35895); Sun, 09 Jun 2019 20:36:02 +0000 Received: (at 35895) by debbugs.gnu.org; 9 Jun 2019 20:35:46 +0000 Received: from localhost ([127.0.0.1]:55468 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ha4XZ-0002uf-EP for submit@debbugs.gnu.org; Sun, 09 Jun 2019 16:35:46 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:46658) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ha4XV-0002uO-PN for 35895@debbugs.gnu.org; Sun, 09 Jun 2019 16:35:43 -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=MbLb/vMAulfI8NSufp3iOrqSZN6naNN0w+/NdfJFukY=; b=M6CPoo42pv702n7Th9xm9o6N9 sobDTZDL/83hzpsFdFf7niSCx9wtYOOe64tLEovAv9u57Vi71iPkUFQZoQ5V7EqxGeKxNJFTDlKvc edaFku7xk1FzWbzXBADdaaHDkNlg3KpWM5jVxnGczeGxkNKZ63JOTSL00AUfKCdwWh3Ss=; Received: from [49.206.15.26] (helo=steel) by systemreboot.net with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ha4XR-0002xJ-Oy; Mon, 10 Jun 2019 02:05:37 +0530 From: Arun Isaac In-Reply-To: <20190603191031.7e751c2a@scratchpost.org> References: <20190525070113.5576-1-arunisaac@systemreboot.net> <20190525072030.7739-1-arunisaac@systemreboot.net> <8736l2iuao.fsf@cbaines.net> <20190603191031.7e751c2a@scratchpost.org> Date: Mon, 10 Jun 2019 02:05:08 +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 Thank you both for the review. I have made the suggested changes. Please find attached an updated patch. In the future, please address me in the Cc or To fields so that I take note sooner. I found your mails only a couple of days ago while going through all my unread mails. :-( From a7b795d9af3347330b48470d3988d43b8038c2c1 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 | 36 +++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm index c1e963d047..95b56b6f4f 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,22 @@ from OS that are needed on the bare metal and not in a container." files))) base))) +(define dummy-networking-shepherd-service + (shepherd-service + (documentation "Provide loopback and networking without actually doing +anything.") + (provision '(loopback networking)) + (start #~(const #t)))) + +(define dummy-networking-service-type + (service-type + (name 'dummy-networking) + (extensions + (list (service-extension + shepherd-root-service-type + (const (list dummy-networking-shepherd-service))))) + (default-value #f))) + (define* (containerized-operating-system os mappings #:key shared-network? @@ -96,7 +113,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 +123,18 @@ 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)) + (list)))) (file-systems (append (map mapping->fs (if shared-network? (append %network-file-mappings mappings) -- 2.21.0