From: Alyssa Ross <hi@alyssa.is>
To: Demi Marie Obenour <demiobenour@gmail.com>
Cc: devel@spectrum-os.org
Subject: Re: [PATCH 2/5] host/rootfs: create a per-VM mount namespace
Date: Mon, 01 Dec 2025 15:33:50 +0100 [thread overview]
Message-ID: <87v7iquv8x.fsf@alyssa.is> (raw)
In-Reply-To: <594830b6-d3a3-42da-84a8-190e08a353e8@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4379 bytes --]
Demi Marie Obenour <demiobenour@gmail.com> writes:
> On 11/30/25 23:45, Alyssa Ross wrote:
>> 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.
>
> Does the updater also need to be adjusted?
It does, thanks for pointing that out. We really need a test for it!
>> Signed-off-by: Alyssa Ross <hi@alyssa.is>
>> ---
>> .../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.
>
> Comment should be moved to the code that does the bind mount. Also,
> this comment is somewhat stale: the main reason to prevent writing
> into the toplevel fs/ folder is that host tools (like the updater)
> assume symlinks can't be created in it.
Good idea.
>> -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 <hi@alyssa.is>
>> +# SPDX-FileCopyrightText: 2024-2025 Alyssa Ross <hi@alyssa.is>
>>
>> -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
> I would also create /run/vm/by-id/${1}/config/fs...
>
>> + }
>> +
>> + 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 }
>
> VMs should not be able to write to their own config, so this and the
> next like should be swapped.
Makes sense.
>> + if { mount --rbind -o nofail /run/vm/by-id/${1}/config/fs /run/vm/by-id/${1}/fs/config }
>
> ...and remove this `-o nofail`.
Not sure about that, since config is likely to be on a different
filesystem we may not even be able to write to. Either way, it's out of
scope here, because it already works this way before this change.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
next prev parent reply other threads:[~2025-12-01 14:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 4:45 [PATCH 1/5] img/app: install fuse3 globally Alyssa Ross
2025-12-01 4:45 ` [PATCH 2/5] host/rootfs: create a per-VM mount namespace Alyssa Ross
2025-12-01 4:52 ` Demi Marie Obenour
2025-12-01 14:33 ` Alyssa Ross [this message]
2025-12-01 4:45 ` [PATCH v4 3/5] tools/mount-flatpak: init Alyssa Ross
2025-12-01 5:14 ` Demi Marie Obenour
2025-12-01 11:49 ` Alyssa Ross
2025-12-01 4:45 ` [PATCH v4 4/5] img/app: run Flatpak applications Alyssa Ross
2025-12-01 4:45 ` [PATCH v4 5/5] host/rootfs: add run-flatpak script Alyssa Ross
2025-12-01 5:20 ` Demi Marie Obenour
2025-12-01 11:17 ` Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v7iquv8x.fsf@alyssa.is \
--to=hi@alyssa.is \
--cc=demiobenour@gmail.com \
--cc=devel@spectrum-os.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).