patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Cc: Yureka Lilian <yureka@cyberchaos.dev>,
	Demi Marie Obenour <demiobenour@gmail.com>
Subject: [PATCH v3 2/3] host/rootfs: put router app sockets in own dir
Date: Tue,  9 Dec 2025 13:54:43 +0100	[thread overview]
Message-ID: <20251209125442.719952-4-hi@alyssa.is> (raw)
In-Reply-To: <20251209125442.719952-2-hi@alyssa.is>

When we have different Cloud Hypervisor instances running as different
users, it makes sense not to permit them to see into each other's
/run/vm directories.  That means we'll need somewhere else to store
router app sockets, which should be accessible by VMs other than the
driver VM associated with the router.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
v3: no change

 host/rootfs/Makefile                               |  1 +
 .../template/data/service/spectrum-router/run      |  2 +-
 tools/start-vmm/lib.rs                             | 14 ++++++++++++--
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile
index 7bec1259..831fdc10 100644
--- a/host/rootfs/Makefile
+++ b/host/rootfs/Makefile
@@ -14,6 +14,7 @@ DIRS = \
 	dev \
 	etc/s6-linux-init/env \
 	etc/s6-linux-init/run-image/configs \
+	etc/s6-linux-init/run-image/router \
 	etc/s6-linux-init/run-image/sd-notify-wrapper \
 	etc/s6-linux-init/run-image/service/serial-getty/instance \
 	etc/s6-linux-init/run-image/service/serial-getty/instances \
diff --git a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/spectrum-router/run b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/spectrum-router/run
index dc1ef900..ec26b76f 100755
--- a/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/spectrum-router/run
+++ b/host/rootfs/image/etc/s6-linux-init/run-image/service/vm-services/template/data/service/spectrum-router/run
@@ -8,7 +8,7 @@ importas -i VM VM
 s6-ipcserver-socketbinder -a 0770 /run/vm/by-id/${VM}/router-driver.sock
 fdmove -c 3 0
 
-s6-ipcserver-socketbinder -a 0770 /run/vm/by-id/${VM}/router-app.sock
+s6-ipcserver-socketbinder -a 0770 /run/router/${VM}
 fdmove -c 4 0
 
 # Notify readiness.
diff --git a/tools/start-vmm/lib.rs b/tools/start-vmm/lib.rs
index b44e0375..2ee87bd9 100644
--- a/tools/start-vmm/lib.rs
+++ b/tools/start-vmm/lib.rs
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: EUPL-1.2+
-// SPDX-FileCopyrightText: 2022-2024 Alyssa Ross <hi@alyssa.is>
+// SPDX-FileCopyrightText: 2022-2025 Alyssa Ross <hi@alyssa.is>
 // SPDX-FileCopyrightText: 2025 Yureka Lilian <yureka@cyberchaos.dev>
 
 mod ch;
@@ -117,6 +117,16 @@ pub fn vm_config(vm_dir: &Path) -> Result<VmConfig, String> {
                         ));
                     }
 
+                    let provider_path = Path::new("/run/vm/by-name").join(&provider_name);
+                    let provider_target = provider_path
+                        .read_link()
+                        .map_err(|e| format!("dereferencing {provider_path:?}: {e}"))?;
+                    let provider_id = provider_target
+                        .file_name()
+                        .ok_or_else(|| format!("{provider_path:?} target has no file name"))?
+                        .to_str()
+                        .ok_or_else(|| format!("{provider_target:?} has non-UTF-8 basename"))?;
+
                     let mut hasher = std::hash::DefaultHasher::new();
                     vm_name.hash(&mut hasher);
                     let id_hashed = hasher.finish();
@@ -132,7 +142,7 @@ pub fn vm_config(vm_dir: &Path) -> Result<VmConfig, String> {
 
                     Ok(NetConfig {
                         vhost_user: true,
-                        vhost_socket: format!("/run/vm/by-name/{provider_name}/router-app.sock"),
+                        vhost_socket: format!("/run/router/{provider_id}"),
                         id: provider_name,
                         mac,
                     })
-- 
2.51.0


  reply	other threads:[~2025-12-09 12:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-09 12:54 [PATCH v3 1/3] tools/router: use socket activation Alyssa Ross
2025-12-09 12:54 ` Alyssa Ross [this message]
2025-12-14  0:13   ` [PATCH v3 2/3] host/rootfs: put router app sockets in own dir Alyssa Ross
2025-12-09 12:54 ` [PATCH v3 3/3] host/rootfs: run router as non-root Alyssa Ross
2025-12-14  0:13   ` Alyssa Ross
2025-12-14  0:13 ` [PATCH v3 1/3] tools/router: use socket activation 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=20251209125442.719952-4-hi@alyssa.is \
    --to=hi@alyssa.is \
    --cc=demiobenour@gmail.com \
    --cc=devel@spectrum-os.org \
    --cc=yureka@cyberchaos.dev \
    /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).