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 6BB3C562; Mon, 01 Dec 2025 04:46:08 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id A9CFF41B; Mon, 01 Dec 2025 04:46:06 +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.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) by atuin.qyliss.net (Postfix) with ESMTPS id 59A46418 for ; Mon, 01 Dec 2025 04:46:05 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id DC5897A0149; Sun, 30 Nov 2025 23:46:02 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Sun, 30 Nov 2025 23:46:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1764564362; x= 1764650762; bh=iLew1/HN2aisEReEMARj/LSJt9ck5w5Wvt5fHVJx7Pc=; b=E VG1WVvi8ttl+wLbxsG8W4SgFCaCnVDAh40Q9dihqXqLfkWkFKolSpZtjQ6uyMpLv zg1K4jXDEZCAIyT+xkiZJ+WUBpjSYGtHH5qFLo19PrxH8en3h/V8MWR7vwZ+uBf3 Jum0cFxFAk1dHqFnrT3buBU7WPYnhFi8/20Yr3kV+VTTaqjNm3DKJEG30yKoCj0Y ipNHgYAjRh86+cD/VR8pRpAdJaayhFdOEwJHBwsgS1MWR3gVJK00FouXTeENT5es swdplnKCnxjGMbq0UeaqDYCrOEtrqRE4Cx+5wC/O4ETyW8vRFBJqqaLCK2+MrnR+ fkf/LJIv6wkI4o0JN0V4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1764564362; x=1764650762; bh=i Lew1/HN2aisEReEMARj/LSJt9ck5w5Wvt5fHVJx7Pc=; b=h/ACReeNvmiopin8M 4nug8dZ8Na4HWgJiHlp16VX3kkfJ54t7fWCwldXj+blMFAR/SLF+bplynLOEvYqK zASNpy6i9jscBAC2fylu9gfQOxKRKjk2p+D1GuXPnXQtg8q2/FMTY3s4LBzYCm/o Krplw+wVTB4mRKDj00PFGJoRpPjKruITq5vwTyGPuykSW374SlMGIY7bip2Juexp UJqaFyMa1uD05z9yBaGiCHZ0Z9deQhGHx+HZPBt5CSrPTY8Jthl8nik/+Q3uSpWf POspWr6QUDrPmJCKi0Sej7GBdBn4/AHQkuv+hUhf0PKi0MQYCmuKIYSr29wXsWTN ANb3Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvheeijeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehlhihsshgr ucftohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepgeeuie duueekkeeivdetffegkeduhfduvedvledvkefhfeeiteekuddujefffeegnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhephhhisegrlhihshhsrg drihhspdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthho peguvghmihhosggvnhhouhhrsehgmhgrihhlrdgtohhmpdhrtghpthhtohepuggvvhgvlh esshhpvggtthhruhhmqdhoshdrohhrgh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 30 Nov 2025 23:46:02 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id 27D1E3F0B310; Mon, 01 Dec 2025 05:45:56 +0100 (CET) From: Alyssa Ross To: devel@spectrum-os.org Subject: [PATCH 2/5] host/rootfs: create a per-VM mount namespace Date: Mon, 1 Dec 2025 05:45:18 +0100 Message-ID: <20251201044534.977524-3-hi@alyssa.is> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251201044534.977524-1-hi@alyssa.is> References: <20251201044534.977524-1-hi@alyssa.is> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: IAJLI4TANIBHDHL2UHPAUGVZI6O3L5VY X-Message-ID-Hash: IAJLI4TANIBHDHL2UHPAUGVZI6O3L5VY X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; 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; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Demi Marie Obenour X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This will solve the problem of mounts for VMs being very annoying to clean up, as evidenced in run-appimage. It was looking to be even worse for Flatpak. Signed-off-by: Alyssa Ross --- .../template/data/service/dbus/run | 2 ++ .../template/data/service/vhost-user-fs/run | 4 +-- .../image/usr/bin/create-vm-dependencies | 23 ++++++++++++++--- host/rootfs/image/usr/bin/run-appimage | 25 +++++++++---------- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/dbus/run b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/dbus/run index 351fc68..9b23192 100755 --- a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/dbus/run +++ b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/dbus/run @@ -4,6 +4,8 @@ importas -i VM VM +nsenter --mount=${VM}/mount + dbus-daemon --config-file /usr/share/dbus-1/session.conf --print-address 3 diff --git a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-fs/run b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-fs/run index 5d5ad7d..3848b0c 100755 --- a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-fs/run +++ b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/vhost-user-fs/run @@ -12,8 +12,6 @@ export TMPDIR /run # The VM should not be able to write directly into a tmpfs, but there # can be writable block-based bind mounted subdirectories. -unshare -m --propagation slave importas -i VM VM -if { mount --rbind -o ro ${VM}/fs ${VM}/fs } - +nsenter --mount=${VM}/mount virtiofsd --fd 3 --shared-dir ${VM}/fs diff --git a/host/rootfs/image/usr/bin/create-vm-dependencies b/host/rootfs/image/usr/bin/create-vm-dependencies index f3a1b69..21681cd 100755 --- a/host/rootfs/image/usr/bin/create-vm-dependencies +++ b/host/rootfs/image/usr/bin/create-vm-dependencies @@ -1,11 +1,26 @@ #!/bin/execlineb -S1 # SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2024 Alyssa Ross +# SPDX-FileCopyrightText: 2024-2025 Alyssa Ross -if { mount -m --rbind -o nofail /run/vm/by-id/${1}/config/fs /run/vm/by-id/${1}/fs/config } +if { touch /run/vm/by-id/${1}/mount } +if { mount --make-private --bind /run/vm/by-id/${1}/mount /run/vm/by-id/${1}/mount } -if { mkdir -p /run/vm/by-id/${1}/doc-run/doc /run/vm/by-id/${1}/fs/doc } -if { mount --rbind /run/vm/by-id/${1}/doc-run/doc /run/vm/by-id/${1}/fs/doc } +if { + unshare --mount=/run/vm/by-id/${1}/mount + + if { + mkdir -p + /run/vm/by-id/${1}/doc-run/doc + /run/vm/by-id/${1}/fs/config + /run/vm/by-id/${1}/fs/doc + } + + if { mount --make-shared --rbind /run/vm/by-id/${1} /run/vm/by-id/${1} } + + if { mount --rbind -o ro /run/vm/by-id/${1}/fs /run/vm/by-id/${1}/fs } + if { mount --rbind -o nofail /run/vm/by-id/${1}/config/fs /run/vm/by-id/${1}/fs/config } + mount --rbind /run/vm/by-id/${1}/doc-run/doc /run/vm/by-id/${1}/fs/doc +} if { s6-instance-create /run/service/vm-services $1 } elglob -0 services /run/service/vm-services/instance/${1}/services/* diff --git a/host/rootfs/image/usr/bin/run-appimage b/host/rootfs/image/usr/bin/run-appimage index 6ccc61f..f2fe7bc 100755 --- a/host/rootfs/image/usr/bin/run-appimage +++ b/host/rootfs/image/usr/bin/run-appimage @@ -1,14 +1,12 @@ #!/bin/execlineb -S1 # SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2024 Alyssa Ross +# SPDX-FileCopyrightText: 2024-2025 Alyssa Ross backtick -E dir { mktemp -d /run/vm/by-id/XXXXXX } backtick -E id { basename -- $dir } if { mkdir -p /run/configs/${id}/fs } -if { redirfd -w 1 /run/configs/${id}/fs/type echo appimage } -if { touch /run/configs/${id}/fs/run } -if { mount --rbind $1 /run/configs/${id}/fs/run } + if { ln -s /usr/lib/spectrum/img/appvm/blk /usr/lib/spectrum/img/appvm/vmlinux /run/configs/${id} @@ -18,6 +16,14 @@ if { ln -s /run/configs/${id} ${dir}/config } if { create-vm-dependencies $id } +if { + nsenter --mount=${dir}/mount + cd ${dir}/fs/config + if { redirfd -w 1 type echo appimage } + if { touch run } + mount --bind $1 run +} + piperw 4 3 background { fdclose 3 @@ -34,13 +40,6 @@ fdclose 3 if { s6-instance-delete /run/service/vm-services $id } -if { - forx -E mount { - /run/configs/${id}/fs/run - ${dir}/fs/config - ${dir}/fs/doc - } - umount $mount -} - +if { umount ${dir}/mount } # mount namespace +if { umount ${dir}/mount } # private bind mount rm -r $dir /run/configs/${id} -- 2.51.0