From: Alyssa Ross <hi@alyssa.is>
To: Yureka <yuka@yuka.dev>
Cc: devel@spectrum-os.org
Subject: Re: [PATCH v2 5/7] host: integrate router
Date: Sat, 29 Nov 2025 15:44:00 +0100 [thread overview]
Message-ID: <87ikes526n.fsf@alyssa.is> (raw)
In-Reply-To: <ce7c49e3-0be6-439b-a486-04b788bff60c@yuka.dev>
[-- Attachment #1: Type: text/plain, Size: 5426 bytes --]
Yureka <yuka@yuka.dev> writes:
> On 11/29/25 14:46, Alyssa Ross wrote:
>> Yureka Lilian <yureka@cyberchaos.dev> writes:
>>
>>> diff --git a/tools/start-vmm/lib.rs b/tools/start-vmm/lib.rs
>>> index 0422d85..246dd6d 100644
>>> --- a/tools/start-vmm/lib.rs
>>> +++ b/tools/start-vmm/lib.rs
>>> @@ -1,23 +1,24 @@
>>> // SPDX-License-Identifier: EUPL-1.2+
>>> // SPDX-FileCopyrightText: 2022-2024 Alyssa Ross <hi@alyssa.is>
>>> +// SPDX-FileCopyrightText: 2025 Yureka Lilian <yureka@cyberchaos.dev>
>>>
>>> mod ch;
>>> mod net;
>>> mod s6;
>>>
>>> use std::borrow::Cow;
>>> -use std::convert::TryInto;
>>> use std::env::args_os;
>>> use std::ffi::OsStr;
>>> use std::fs::File;
>>> -use std::io::{self, ErrorKind};
>>> +use std::hash::{Hash, Hasher};
>>> +use std::io::ErrorKind;
>>> use std::path::Path;
>>>
>>> use ch::{
>>> - ConsoleConfig, DiskConfig, FsConfig, GpuConfig, LandlockConfig, MemoryConfig, PayloadConfig,
>>> - VmConfig, VsockConfig,
>>> + ConsoleConfig, DiskConfig, FsConfig, GpuConfig, LandlockConfig, MemoryConfig, NetConfig,
>>> + PayloadConfig, VmConfig, VsockConfig,
>>> };
>>> -use net::net_setup;
>>> +use net::MacAddress;
>>>
>>> pub fn prog_name() -> String {
>>> args_os()
>>> @@ -40,8 +41,6 @@ pub fn vm_config(vm_dir: &Path) -> Result<VmConfig, String> {
>>> return Err(format!("VM name may not contain a colon: {vm_name:?}"));
>>> }
>>>
>>> - let name_bytes = vm_name.as_bytes();
>>> -
>>> let config_dir = vm_dir.join("config");
>>> let blk_dir = config_dir.join("blk");
>>> let kernel_path = config_dir.join("vmlinux");
>>> @@ -97,24 +96,51 @@ pub fn vm_config(vm_dir: &Path) -> Result<VmConfig, String> {
>>> shared: true,
>>> },
>>> net: match net_providers_dir.read_dir() {
>>> - Ok(_) => {
>>> - // SAFETY: we check the result.
>>> - let net = unsafe {
>>> - net_setup(
>>> - name_bytes.as_ptr().cast(),
>>> - name_bytes
>>> - .len()
>>> - .try_into()
>>> - .map_err(|e| format!("VM name too long: {e}"))?,
>>> - )
>>> - };
>>> - if net.fd == -1 {
>>> - let e = io::Error::last_os_error();
>>> - return Err(format!("setting up networking failed: {e}"));
>>> - }
>>> -
>>> - vec![net.try_into().unwrap()]
>>> - }
>>> + Ok(entries) => entries
>>> + .into_iter()
>>> + .map(|result| {
>>> + Ok(result
>>> + .map_err(|e| format!("examining directory entry: {e}"))?
>>> + .path())
>>> + })
>>> + .map(|result: Result<_, String>| {
>>> + let provider_name = result?.file_name().ok_or("unable to get net provider name".to_string())?.to_str().unwrap().to_string();
>>> +
>>> + if provider_name.contains(',') {
>>> + return Err(format!("illegal ',' character in net provider name {provider_name:?}"));
>>> + }
>>> +
>>> + let mut hasher = std::hash::DefaultHasher::new();
>>> + vm_name.hash(&mut hasher);
>>> + let id_hashed = hasher.finish();
>>> +
>>> + let mac = MacAddress::new([
>>> + 0x02, // IEEE 802c administratively assigned
>>> + 0x00, // Spectrum client
>>> + (id_hashed >> 24) as u8,
>>> + (id_hashed >> 16) as u8,
>>> + (id_hashed >> 8) as u8,
>>> + id_hashed as u8,
>>> + ]);
>>> +
>>> + let provider_id = std::fs::read_link(format!("/run/vm/by-name/{provider_name}")).map_err(|e| format!("unable to get net provider id: {e}"))?.file_name().ok_or("unable to get net provider id".to_string())?.to_str().unwrap().to_string();
>>> +
>>> + let svc_dir = format!("/run/service/vm-services/instance/{provider_id}/data/service/spectrum-router");
>>> + let svc_status = std::process::Command::new("s6-svc")
>>> + .args(["-U", &svc_dir])
>>> + .status()
>>> + .expect("setting up the upstream router via s6-svc failed");
>>> + if !svc_status.success() {
>>> + return Err(format!("setting up the upstream router via s6-svc failed with exit code {svc_status}"));
>>> + }
>> I'd prefer this was in run-vmm, since it's a bit surprising to stop in
>> the middle of constructing a Cloud Hypervisor API request to do service
>> management.
>
> Is it by any chance even guaranteed that at the point when run-vmm for
> this VM runs, the vmm for the provider VM would already be up? That
> would simplify the process and make assign-driver-router-iface
> unnecessary because there would be one place where we can add the interface.
No, but you could s6-svwait in there, in the existing background block.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
next prev parent reply other threads:[~2025-11-29 14:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 22:30 [PATCH v2 0/7] spectrum-router Yureka Lilian
2025-11-28 22:30 ` [PATCH v2 1/7] vm/sys/net: remove connman Yureka Lilian
2025-11-29 13:06 ` Alyssa Ross
2025-11-28 22:30 ` [PATCH v2 2/7] vm/sys/net: integrate xdp-forwarder Yureka Lilian
2025-11-29 13:08 ` Alyssa Ross
2025-11-29 13:15 ` Yureka
2025-11-29 13:17 ` Alyssa Ross
2025-11-28 22:30 ` [PATCH v2 3/7] vm/sys/net: add iwd Yureka Lilian
2025-11-29 13:09 ` Alyssa Ross
2025-11-28 22:30 ` [PATCH v2 4/7] tools: add spectrum-router Yureka Lilian
2025-11-29 13:18 ` Alyssa Ross
2025-11-28 22:30 ` [PATCH v2 5/7] host: integrate router Yureka Lilian
2025-11-29 13:46 ` Alyssa Ross
2025-11-29 14:28 ` Yureka
2025-11-29 14:44 ` Alyssa Ross [this message]
2025-11-28 22:30 ` [PATCH v2 6/7] img/app: change to ipv6 nameserver Yureka Lilian
2025-11-29 13:20 ` Alyssa Ross
2025-11-28 22:30 ` [PATCH v2 7/7] checks/integration: Adapt networking test for ipv6 Yureka Lilian
2025-11-29 13:26 ` 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=87ikes526n.fsf@alyssa.is \
--to=hi@alyssa.is \
--cc=devel@spectrum-os.org \
--cc=yuka@yuka.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).