From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id IIHsNTSkH2FbHQAAgWs5BA (envelope-from ) for ; Fri, 20 Aug 2021 14:46:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id ENacMTSkH2EYSgAAB5/wlQ (envelope-from ) for ; Fri, 20 Aug 2021 12:46:44 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8089AD4C3 for ; Fri, 20 Aug 2021 14:46:44 +0200 (CEST) Received: from localhost ([::1]:55062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mH3v0-0006oO-Ov for larch@yhetil.org; Fri, 20 Aug 2021 08:46:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mH3uO-00063v-KA for guix-patches@gnu.org; Fri, 20 Aug 2021 08:46:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mH3uO-0005xt-BI for guix-patches@gnu.org; Fri, 20 Aug 2021 08:46:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mH3uO-0002WB-AB for guix-patches@gnu.org; Fri, 20 Aug 2021 08:46:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50133] [PATCH 6/6] services: Add lxd-service-type. Resent-From: Andrew Whatson Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 20 Aug 2021 12:46:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50133 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50133@debbugs.gnu.org Cc: Andrew Whatson Received: via spool by 50133-submit@debbugs.gnu.org id=B50133.16294635559621 (code B ref 50133); Fri, 20 Aug 2021 12:46:04 +0000 Received: (at 50133) by debbugs.gnu.org; 20 Aug 2021 12:45:55 +0000 Received: from localhost ([127.0.0.1]:33168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mH3uF-0002V6-6U for submit@debbugs.gnu.org; Fri, 20 Aug 2021 08:45:55 -0400 Received: from mail-pl1-f182.google.com ([209.85.214.182]:36771) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mH3uC-0002UT-E3 for 50133@debbugs.gnu.org; Fri, 20 Aug 2021 08:45:53 -0400 Received: by mail-pl1-f182.google.com with SMTP id f3so5918001plg.3 for <50133@debbugs.gnu.org>; Fri, 20 Aug 2021 05:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zaay0zqaW9tDBHezB7RohNKntuupO15p/hxyAsP5H+Y=; b=KcLtEJmCgv86T3YPGmBJLcjc3oGhiM1TDER2MxbI/bYV7LSh4dEl85qO6DfA08vLzB kbJtyrmIT4f3d0Apk07CgvOtY1oAueGHKpXyU/VB3lug9UnjBfIafZ8SPaki2f5nXdVI oml/N+uqPVd8bS9dYQsntcXj3z1L+oxU9xUJNxOrITLv0CkzGX4YIWfLfNIcQSojowax NEVZ5L7q7Wx4rOWG3WS1mNPi/uchZwTpa1HY/YmwRaAzhxl6IL7UurLhB2RXB2SxhAkY kTp9a9JrkQw0AtvZrNweT2ZxcVDULgR0xvCgwLAQKF1+ZFDjKQDTXj0OWY1apxY8XzJy iHPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zaay0zqaW9tDBHezB7RohNKntuupO15p/hxyAsP5H+Y=; b=V06eS40JPP6I8EwNsaxa9yNtpFUqRYgnoKyUS2uW+Q+2GceMFX2zClRHrZPu3eZzNZ MoKjHQsPBfc+GYB+ey9Spx05QGDJyCIGcQnJusi/sR3vCZW3cO2dAdWrCYke83o2vAOJ IouJCf2o5WkT1i56xW6vqAe55wDbG0/YUjH5+qJ5Hv0cOwzEIy+BuF+6OrfwpLsvw3rf QDi8CsCsA4kB5uSQ025NWoXuH7KXdo+3rOQGjW58e/Tikz5yAzbO5lV+MwQKP6DpEssT awT02rNV33aq4EKEjVo7xwGXYudx6b5G87Tfzcb6yU6pSjKNqkETo0TWg2rQTTDq6d+g QZyQ== X-Gm-Message-State: AOAM532gFsVZKn3vdqb3ESji5q7epxgwFezgwQ75pwjXZ1nOPGJPacsc dzmLB9W2YoBVW38Kb6l5w/x4Ct+lCME= X-Google-Smtp-Source: ABdhPJyJ1v4vYO7s49xUPyl/J6XmRCKI+h7i27ZTNb43v0dBPOhe8gNb+6UNVYf1Jb2VW33gZ4IPxw== X-Received: by 2002:a17:90a:8b95:: with SMTP id z21mr4344297pjn.131.1629463546622; Fri, 20 Aug 2021 05:45:46 -0700 (PDT) Received: from muon.fritz.box (220-235-208-141.tpgi.com.au. [220.235.208.141]) by smtp.gmail.com with ESMTPSA id o10sm5113868pfk.212.2021.08.20.05.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:45:46 -0700 (PDT) From: Andrew Whatson Date: Fri, 20 Aug 2021 22:45:24 +1000 Message-Id: <20210820124524.117090-6-whatson@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210820124524.117090-1-whatson@gmail.com> References: <20210820124524.117090-1-whatson@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1629463604; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=3vEANZsXdt8Hrsu1bcPPVm6awIslcfJ+VWfPb//UEmk=; b=AB5NkzWfUYTFbG1lln5v8igDCxYCZqsQNxrzkpfSE2YsPXs7t1CjZea9EgeG43/TFSo5eS V6aFvmNpK9sDXOVd1q8Gyp2cjiitLTYPVPibfGMfC2GbGzXdwL0QufeKAruDXoTtqazLCs RJq25UfrxradnoGaky6sqZEh7Os87tVAwI3xWkqk5EBmsEe+cJPDECL1YYGr47MXhhkA6G 205CBKNPfl0AzSh84FSH/1IdxABHphay+lGZpPFs5KovqQql8pVVvrW5hhK4G8K6EgL+7K Nwf/MRGWNefQS4DDa2RCyV+nD+fRMP7H2Cu/LR9dDhBHM5xfmSmYmTXFyThhVQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1629463604; a=rsa-sha256; cv=none; b=rS2NqncQzHPdpAVakhbVCiT/JtK/dQqXE+8yQt2CTf72i+kz74rOGSoZniCIh3zd5mT2E3 bVsndo+/KPcdbcObznniDW1OIwL6evmfcb3mvqVpklyUj/x0tuPF68jm77RASXk1Jw03zS G8AnJEAUqIsTAGI7ycWlSlABoSk35j5SJ+gZn8eyQpza59Dq+OjESJN3U2qmiuBEKAv38k 5zh7Tcy00R8/wOxnMFK51dLhVO7Ah6lOe7FPoSOYWPddR5xtfer4lw6i6iqK1mvOucYInI Q7uqIB1qbohLS1fhEYxJSnjlLYvHAEWCcgxJ+yg1hX87TYvqnPc4tOSrmejvew== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=KcLtEJmC; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 3.68 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=KcLtEJmC; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 8089AD4C3 X-Spam-Score: 3.68 X-Migadu-Scanner: scn0.migadu.com X-TUID: K3M2yVDEvxi4 * gnu/services/virtualization.scm (lxd-configuration): New type. (%lxd-accounts, lxd-service-type): New variables. (%lxd-activation, lxd-shepherd-service): New procedures. * gnu/system/file-systems.scm (%elogind-file-systems): Add "/sys/fs/cgroup/systemd" file-system. --- gnu/services/virtualization.scm | 66 +++++++++++++++++++++++++++++++++ gnu/system/file-systems.scm | 11 ++++++ 2 files changed, 77 insertions(+) diff --git a/gnu/services/virtualization.scm b/gnu/services/virtualization.scm index c8adcd06d0..34ddc94423 100644 --- a/gnu/services/virtualization.scm +++ b/gnu/services/virtualization.scm @@ -75,6 +75,9 @@ virtlog-configuration virtlog-service-type + lxd-configuration + lxd-service-type + %qemu-platforms lookup-qemu-platforms qemu-platform? @@ -548,6 +551,69 @@ potential infinite waits blocking libvirt.")) `((libvirt-configuration ,libvirt-configuration-fields)) 'libvirt-configuration)) + +;;; +;;; LXD linux container daemon. +;;; + +(define-configuration lxd-configuration + (lxd + (package lxd) + "LXD package.") + (debug? + (boolean #f) + "Enable or disable debug messages.") + (verbose? + (boolean #f) + "Enable or disable information messages.")) + +(define %lxd-accounts + (list (user-group (name "lxd") (system? #t)))) + +(define (%lxd-activation config) + #~(begin + (use-modules (guix build utils)) + (mkdir-p "/var/log/lxd"))) + +(define (lxd-shepherd-service config) + (let* ((lxd (lxd-configuration-lxd config)) + (debug? (lxd-configuration-debug? config)) + (verbose? (lxd-configuration-verbose? config))) + (list + (shepherd-service + (documentation "LXD daemon.") + (provision '(lxd)) + (requirement '(dbus-system + elogind + file-system-/sys/fs/cgroup/blkio + file-system-/sys/fs/cgroup/cpu + file-system-/sys/fs/cgroup/cpuset + file-system-/sys/fs/cgroup/devices + file-system-/sys/fs/cgroup/memory + file-system-/sys/fs/cgroup/pids + file-system-/sys/fs/cgroup/systemd + networking + udev)) + (start #~(make-forkexec-constructor + (list (string-append #$lxd "/bin/lxd") + "--group=lxd" + "--logfile=/var/log/lxd/lxd.log" + #$@(if debug? '("--debug") '()) + #$@(if verbose? '("--verbose") '())))) + (stop #~(make-kill-destructor)))))) + +(define lxd-service-type + (service-type + (name 'lxd) + (extensions + (list (service-extension activation-service-type + %lxd-activation) + (service-extension shepherd-root-service-type + lxd-shepherd-service) + (service-extension account-service-type + (const %lxd-accounts)))) + (default-value (lxd-configuration)))) + ;;; ;;; Transparent QEMU emulation via binfmt_misc. diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index b9eda80958..7c3777298b 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -499,6 +499,17 @@ TARGET in the other system." (check? #f) (options "none,name=elogind") (create-mount-point? #t) + (dependencies (list (car %control-groups)))) + ;; The systemd cgroup needs to exist to run systemd inside linux + ;; containers (eg. via LXD). This is *not* required for elogind, but + ;; keeping it with the other systemd hacks seemed sensible, for now. + (file-system + (device "cgroup") + (mount-point "/sys/fs/cgroup/systemd") + (type "cgroup") + (check? #f) + (options "none,name=systemd") + (create-mount-point? #t) (dependencies (list (car %control-groups))))) %control-groups)) -- 2.32.0