From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 1CF931C8B; Sat, 11 Jul 2026 20:14:30 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 218971B45; Sat, 11 Jul 2026 20:14:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yx1-xb12e.google.com (mail-yx1-xb12e.google.com [IPv6:2607:f8b0:4864:20::b12e]) by atuin.qyliss.net (Postfix) with ESMTPS id 9F77B1B3E for ; Sat, 11 Jul 2026 20:14:23 +0000 (UTC) Received: by mail-yx1-xb12e.google.com with SMTP id 956f58d0204a3-664cb440f9eso2641415d50.1 for ; Sat, 11 Jul 2026 13:14:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783800862; x=1784405662; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=F8+LrGpOHkod54C6TeCvOMQJftCME8fUX7e9ifUltI0=; b=SPPqr9HuvCpCOxYGrXTrVDSNL9/IhViFBOu3DcGhgQxbOJ7Eet3Z/Neq/Y+9tDVVZB OTWqq+53bstXjRjkCkOlXQQM8KQb5Y8mxN8I/I7bjOjiGURqAj3m5jYmoV3MPfGDwabP hUArHE4lsYhm735RYfxFIyAuirFlc5MABx5I50wTfLLOXmTeORSJDS6sEg1hZzwRqH9Y 4G5casJ7fBG4tGvIkcfYFKeHTiUVCZ+tKNS+7EHuKvwccIDxLsF6UIFJ90Y9zhSNr5iq fvldtVmrRax8KOzbdHDaFCYowggpJ0xOBS/j9jA6LB780wYNxNyZKE3NBZ6GBhNEUXDP E5ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783800862; x=1784405662; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=F8+LrGpOHkod54C6TeCvOMQJftCME8fUX7e9ifUltI0=; b=n1ZMO4LWsTH+5lkCNVNaB1eurGOIghVwuodP50ajrv7iD3iWfrIbTclMB7weAgYBtp l6N/sdmCtPiTxDON3YcWSr4F70B/d7SGUPxXg69lLAvZzJ5CpbD8OpbEPBMoBOkvvgyC SfY4dIlKoBOVA7gvKaOEUiwVzhUyXP1o1I1rNMTr/s93dSvwrHhtbcFjjb10O6ln5Xc5 yzNFGyjXfLw8cHZ84MA2YHdyhXyQBO3YANE7JBc7Z1dIhoGgshqbolxFbFFAnNbVJO2M W6MyUxP/nQ6cXg3aXy+4I9m++Auvo67pVHssyXZIlFEAZKJze6Bk4Ws/kb6eHiizaBrX T0Kw== X-Gm-Message-State: AOJu0YwAZQXcpLUVV9bNCRmUwh0b9dC2G5xQRMOsJKBF8uqBEdJ690BS RimsKLoHcnRzjwKjjzl+b4nFLB+FlCK59V2HWzkcXpJ9PngUUEedQVeHGaIWbA== X-Gm-Gg: AfdE7ckLt42wUPVZP1yp77graL96v2tuB5UIKMEZyhAmjlee535ZKaiFNRB+uCApxN2 V0/3f8XjHMz8hkkUWbJTRLhBujOGreyFjKAU+wFFFG+X/c/5UVuspet3ccYU84CTPn2yRRjOpv4 1k5u6g9nKlrAAsvArHvOjG5cf+v4/VobQf256ywA4ZmhLWz3ESHoDL24GgDFDsxnDolr0dp1FBj eZIa2GbFUL0S0ojFfFX1CeI8Z30AmPkbHb1NWrR5DABZZRaJpYuPyguV0wf4D8UoTsxpuhrS3uw M30jPRQPQcP268YXTc5rp5eeYz2SH7iL1+JN/IMI68H/FTE4Vs1Mg8ZZSpHMOcLNZoVdvVR5Vdv xYAcjrGOzQYnderyBxtlK3g3gnycYlhdEnppp0Uy4VWpBf+ANdlhqmkYxwdffhd9xyf6/5EZxAz yz4u+zPV2OUDCV4JGjb05lCCAiSGAgzeQQGZfG X-Received: by 2002:a05:690e:b83:b0:667:ba06:8888 with SMTP id 956f58d0204a3-667d7eeddd9mr2705508d50.98.1783800862321; Sat, 11 Jul 2026 13:14:22 -0700 (PDT) Received: from localhost.localdomain ([185.98.168.14]) by smtp.gmail.com with UTF8SMTPSA id 956f58d0204a3-66787ad3833sm9952217d50.20.2026.07.11.13.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 13:14:21 -0700 (PDT) From: Demi Marie Obenour Date: Sat, 11 Jul 2026 16:12:10 -0400 Subject: [PATCH v3 06/22] host/rootfs: Add helper program for per-VM services MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260711-cgroups-v3-6-5cba61a20cba@gmail.com> References: <20260711-cgroups-v3-0-5cba61a20cba@gmail.com> In-Reply-To: <20260711-cgroups-v3-0-5cba61a20cba@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783800724; l=2407; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=tkKjZSIYWo9qoPSyQNsxA40RxffVymoRigvyWWVcm40=; b=YzFNe3XlBqIPdGRE2qRIeA4dL8Phgt9By2DNyj0TmEykiiXnGR/psCQdJZVyHrL+dVnAHj4RQ F3t+l5618iWAD1zCpk6PF2PV1uGHF5dNeNV7NdSrX1+N9w7vmw6qUCB X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: EFDQYGZWYSSBEWKNCCEOB6H4R6NJSMA2 X-Message-ID-Hash: EFDQYGZWYSSBEWKNCCEOB6H4R6NJSMA2 X-MailFrom: demiobenour@gmail.com X-Mailman-Rule-Hits: member-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; emergency CC: Demi Marie Obenour , Alyssa Ross X-Mailman-Version: 3.3.10 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The program handles cgroups and common substitutions. This is better than repeating the boilerplate multiple times. Signed-off-by: Demi Marie Obenour --- host/rootfs/file-list.mk | 1 + host/rootfs/image/usr/bin/vm-service-run | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/host/rootfs/file-list.mk b/host/rootfs/file-list.mk index 7e44fc612a5a9ac8767be9148cdc71869ef16964..9375a05a6847ed2b799a13d7be74313459fc9f0e 100644 --- a/host/rootfs/file-list.mk +++ b/host/rootfs/file-list.mk @@ -65,6 +65,7 @@ FILES = \ image/usr/bin/spectrum-update \ image/usr/bin/vm-console \ image/usr/bin/vm-import \ + image/usr/bin/vm-service-run \ image/usr/bin/vm-start \ image/usr/bin/vm-stop \ image/usr/bin/xdg-open \ diff --git a/host/rootfs/image/usr/bin/vm-service-run b/host/rootfs/image/usr/bin/vm-service-run new file mode 100755 index 0000000000000000000000000000000000000000..c788574cf95ec7fd0d93b656557f85fa80b31690 --- /dev/null +++ b/host/rootfs/image/usr/bin/vm-service-run @@ -0,0 +1,34 @@ +#!/usr/bin/execlineb -WS1 +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2026 Demi Marie Obenour + +# Substitute all of the needed environment variables +# into both this script and its arguments +# (the subsequent command to run). This substitutes +# the *caller*'s arguments. +multisubstitute { + importas -iS VM + importas -iS "#" + importas -iS "1" + importas -iS WAYLAND_DISPLAY +} + +# Check that the VM name and service are reasonable. +# Then run the cgroup-setup program and the provided +# command line. Avoid premature substitution by +# escaping ${#} and ${1} with backslashes. Otherwise, +# they would be values for this script, not for the caller. +case -- "\\${#}@${VM}@\\${1}" { + # s6-supervise might start passing extra arguments in the future, but + # 0 arguments is not okay. + "[1-9][0-9]*@[A-Za-z0-9_][A-Za-z0-9_.-]*@[A-Za-z_][A-Za-z0-9_-]*" { + # The caller has been migrated from using -WS1 to using -Wp. + # Pop the environment to preserve the original behavior. + emptyenv -P cgroup-setup --leaf -- "\\${1}" $@ + } +} +fdmove -c 1 2 +if { printf "Wrong VM name %s, \ +parent argument count %s, or parent argument %s\n" + $VM "\\$#" "\\${1}" } +exit 100 -- 2.55.0