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 AF3D566AF; Wed, 22 Jul 2026 02:16:59 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 28F3465F2; Wed, 22 Jul 2026 02:16:57 +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-xb131.google.com (mail-yx1-xb131.google.com [IPv6:2607:f8b0:4864:20::b131]) by atuin.qyliss.net (Postfix) with ESMTPS id CDF0665E3 for ; Wed, 22 Jul 2026 02:16:55 +0000 (UTC) Received: by mail-yx1-xb131.google.com with SMTP id 956f58d0204a3-66804667af2so6415280d50.0 for ; Tue, 21 Jul 2026 19:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784686614; x=1785291414; 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=648qCE8EwnvlfvoDsqRLmGAlwj4kjtandQMUBtZL6t4=; b=FbTiaS614CXP4cTJx9ZroZK3nfchlRJ8A73j0wkP0qVvn6da5w0UAgEj4wEoQO1/ce nlAyuk++AzsQl/F3ucnDXSMWAZaGwfRnM2xCyvh02eN5/j7k2KkavH1qPZL6xFMo4LS7 KEEUWfivCoCmKSUsqYN5Wg7XlA6Sruu8nqv5g5EGGSI+DFe02vvWpXfctC10/g0+9Z4n uPIT0K/skoXlzG1DWwtXLhrcYPBy2BE9A/j2pA5ngE9ZTWlBawJaDWTb1NhcV8OvWnNR uXJda/w50e3/d+wCgt02IXNLAs8zf5MAYVu4E688pGW9ebzF+scqwpcqiUiLPubhFAEP vniw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784686614; x=1785291414; 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=648qCE8EwnvlfvoDsqRLmGAlwj4kjtandQMUBtZL6t4=; b=s7TMp5x90g6kvOo9IXMwfkkJDdHm2oo+F+VLBv7IKyYkh3SF+Mc+JZZLKpx1f9Lb7+ lexxF3h5jY1x8iE2pr5ni+oQsrG9w26N8QxeWhr8WNf1xFGkSGHF7LrvGMl6Zau7vjK3 lKrJ9S65OnlJflygQfdVrxlLRFwd7ReJcag80Ise1sD2VvYkryA5tIJNL25C4bMlCL20 +l0tgY8IpNyQlxPfDKEmAHAtmPyBKZbuWNpSPaHoO6ckSPLhFBi5uwjpnqiKRAjsAaSv jUlCmd7VWyIKSNGpsg0mWHzG/jRcqkpKklA1OIpyMd3q+AFORD96hKSMe2qD3T7QBaPX baNQ== X-Gm-Message-State: AOJu0YzB8G9BQVy4eOzaKsz5lj5n0gEZT6eHrmf0cyYMxdyW5JmiSXgG IkvoJLAWtL6b2Br8rxz2XajAfXV1+jik7Q2KbO2bgrO3vFWRUDnzRCX2B+10fQ== X-Gm-Gg: AR+sD10kdwDoHJvqTCJsCqZSXn7/7GiMgIX+ocektn/Mxd7+Bm0NC9rVgah3ed+N5sI 2fMwbslnbYutfFQYugWP53crZTVfHg5o28zIgXJxatm4NXpWBzUvSMQ133+ljMbNpxXIwk2gqMA PjC7rwMVJgj4q8Ot4f1sgVTRx+ZJQe/TupnXGbticfrX9yRF0FItsdxFceTgQcaMQxrLGzUbr63 VTS7DqmFoTAVHwTtz899NUE0iHUOPbytQFIeQ89hTSWYU/oUDTYB3KfrD36W0GiM07Ppz1y/Z2X yu2qW3dPSQJVpGsh9m2/fhHtqIOwWd+h2XmYTgEgWU4q26y/3k5X1AwOzGJEZdvc7HLrdlW6RYe qXyoq1R2ltVbNCQ39hT77OK7P7MxoeTEgXb7qEhFqmtdimZRMTjmowe84xEGbFOLLxGP32S4xAv wjxko56wEEoW2i0Ks= X-Received: by 2002:a53:bd51:0:b0:667:fa8b:fcd3 with SMTP id 956f58d0204a3-6683bbe4f41mr3860282d50.45.1784686614145; Tue, 21 Jul 2026 19:16:54 -0700 (PDT) Received: from localhost.localdomain ([185.98.168.14]) by smtp.gmail.com with UTF8SMTPSA id 956f58d0204a3-66890775512sm562863d50.19.2026.07.21.19.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 19:16:53 -0700 (PDT) From: Demi Marie Obenour Date: Tue, 21 Jul 2026 21:59:10 -0400 Subject: [PATCH v4 05/20] 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: <20260721-cgroups-v4-5-46b2e5fff7b6@gmail.com> References: <20260721-cgroups-v4-0-46b2e5fff7b6@gmail.com> In-Reply-To: <20260721-cgroups-v4-0-46b2e5fff7b6@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784685545; l=2407; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=On2kTwfTb/eJSoM53oeCSh3B+XRgPxYVfxtgi9Ftyws=; b=93lV5UqRScL0lTbBKIwNyRBRhQYcd31fvJjQ+yzfWMaBHuCo+Gw+Ur/2VIN8A8EWBxjCSaTDH w/2T0No/3ZPDWQ1tGI7kf7g/D1uPFoJ6ddXMGH7bqtUXWzim47CJ1vs X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: G7FSHXTKHJ6SCCP5I3IOONXPNV45V4TM X-Message-ID-Hash: G7FSHXTKHJ6SCCP5I3IOONXPNV45V4TM 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 e1280ab56d8797e40b9b1c584ab0daef3cda41d7..c707c01179238231f70164ffda5b7c940b34192a 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