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 428AC1E3CA; Sat, 29 Nov 2025 14:44:11 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id DCEB41E456; Sat, 29 Nov 2025 14:44:08 +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 fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) by atuin.qyliss.net (Postfix) with ESMTPS id B368C1E455 for ; Sat, 29 Nov 2025 14:44:07 +0000 (UTC) Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.stl.internal (Postfix) with ESMTP id 903CC1D00239; Sat, 29 Nov 2025 09:44:04 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Sat, 29 Nov 2025 09:44:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-type: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=1764427444; x=1764513844; bh=pa4hBapnqf OBJiHjiMzyzlCSwUtSrghIIEPfJw3v1+g=; b=O/6bqF+RW6UYS87qXZw316uuNV ddlc7+sGKncM85xFjxNwnhlnMg8NfVIYRCRk6Y1Lr4Fy74Hgx2M3ra5n/iDQy5Kp YD88Gv+HTIv0dX4rcqKSLUww36eIQoWhG+UDZX7fTFTbqTNNkW0cF8C9o1tYD7Py mfiq1WyYD95QueedqgpeIfnd7SVU8q775DlYv3LbO927y99vKbhfJUsQiR3sODWq Nxr87hy0yijnkb4XTaDFsMwJ8krvYXNVjh+9tByDxGGasyQrdNqLpTgs5HkzheDv xxvn02dykXmqVOWOsKFXarOjypYmPcONp9c/CgFWrStLSYm8oJ2xtFEGSD1g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type: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= 1764427444; x=1764513844; bh=pa4hBapnqfOBJiHjiMzyzlCSwUtSrghIIEP fJw3v1+g=; b=fQ+SCN7gMq5K3NuIY7oyMd3UZ3PWhaJED8LPBQt9GiR2L981Imm Cr7q66ccHQn9o8sVdD3CVKt27O6TjrS8oHlKo0BpEiOHgiYuVQwY7Z1txBuFO4+Q 8k5xtFzVMYcL3uxB4o8XyRslmcZ/GpHmLaMb7/fHPcs93/CrmV+GubP4xbycnTdq MWBEwPjYKmCIK5wbHlAeGoI+HpqpjeaNKOXd4t1P68+vssgqDew25y6U1lIKrel4 rHjg515A4GfroLEiQEnd6RbNasJEvK36owESPJ09ae8pfJYZyB4V05UiC071JrAN HvjbBqJbk6KhCESWPqvgbiKKm6APUO7uUCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvhedvjeefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefhvfevufgjfhffkfggtgesghdtreertd dttdenucfhrhhomheptehlhihsshgrucftohhsshcuoehhihesrghlhihsshgrrdhisheq necuggftrfgrthhtvghrnhepieduffeuieelgfetgfdttddtkeekheekgfehkedufeevte egfeeiffetvdetueevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhephhhisegrlhihshhsrgdrihhspdhnsggprhgtphhtthhopedvpdhmohguvg epshhmthhpohhuthdprhgtphhtthhopeguvghvvghlsehsphgvtghtrhhumhdqohhsrdho rhhgpdhrtghpthhtohephihukhgrseihuhhkrgdruggvvh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 29 Nov 2025 09:44:03 -0500 (EST) Received: by fw12.qyliss.net (Postfix, from userid 1000) id 9012D2F426BF; Sat, 29 Nov 2025 15:44:01 +0100 (CET) From: Alyssa Ross To: Yureka Subject: Re: [PATCH v2 5/7] host: integrate router In-Reply-To: References: <20251128223038.97536-1-yureka@cyberchaos.dev> <20251128223038.97536-6-yureka@cyberchaos.dev> <87ldjp3q9o.fsf@alyssa.is> Date: Sat, 29 Nov 2025 15:44:00 +0100 Message-ID: <87ikes526n.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: BGZOEKEU6KGBHISTGGWX6Q3MD3O6DIGW X-Message-ID-Hash: BGZOEKEU6KGBHISTGGWX6Q3MD3O6DIGW 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: devel@spectrum-os.org 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: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Yureka writes: > On 11/29/25 14:46, Alyssa Ross wrote: >> Yureka Lilian 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 >>> +// SPDX-FileCopyrightText: 2025 Yureka Lilian >>>=20=20=20 >>> mod ch; >>> mod net; >>> mod s6; >>>=20=20=20 >>> 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; >>>=20=20=20 >>> use ch::{ >>> - ConsoleConfig, DiskConfig, FsConfig, GpuConfig, LandlockConfig, Me= moryConfig, PayloadConfig, >>> - VmConfig, VsockConfig, >>> + ConsoleConfig, DiskConfig, FsConfig, GpuConfig, LandlockConfig, Me= moryConfig, NetConfig, >>> + PayloadConfig, VmConfig, VsockConfig, >>> }; >>> -use net::net_setup; >>> +use net::MacAddress; >>>=20=20=20 >>> pub fn prog_name() -> String { >>> args_os() >>> @@ -40,8 +41,6 @@ pub fn vm_config(vm_dir: &Path) -> Result { >>> return Err(format!("VM name may not contain a colon: {vm_name= :?}")); >>> } >>>=20=20=20 >>> - let name_bytes =3D vm_name.as_bytes(); >>> - >>> let config_dir =3D vm_dir.join("config"); >>> let blk_dir =3D config_dir.join("blk"); >>> let kernel_path =3D config_dir.join("vmlinux"); >>> @@ -97,24 +96,51 @@ pub fn vm_config(vm_dir: &Path) -> Result { >>> shared: true, >>> }, >>> net: match net_providers_dir.read_dir() { >>> - Ok(_) =3D> { >>> - // SAFETY: we check the result. >>> - let net =3D 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 =3D=3D -1 { >>> - let e =3D io::Error::last_os_error(); >>> - return Err(format!("setting up networking failed: = {e}")); >>> - } >>> - >>> - vec![net.try_into().unwrap()] >>> - } >>> + Ok(entries) =3D> entries >>> + .into_iter() >>> + .map(|result| { >>> + Ok(result >>> + .map_err(|e| format!("examining directory entr= y: {e}"))? >>> + .path()) >>> + }) >>> + .map(|result: Result<_, String>| { >>> + let provider_name =3D result?.file_name().ok_or("u= nable to get net provider name".to_string())?.to_str().unwrap().to_string(); >>> + >>> + if provider_name.contains(',') { >>> + return Err(format!("illegal ',' character in n= et provider name {provider_name:?}")); >>> + } >>> + >>> + let mut hasher =3D std::hash::DefaultHasher::new(); >>> + vm_name.hash(&mut hasher); >>> + let id_hashed =3D hasher.finish(); >>> + >>> + let mac =3D 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 =3D std::fs::read_link(format!("/r= un/vm/by-name/{provider_name}")).map_err(|e| format!("unable to get net pro= vider id: {e}"))?.file_name().ok_or("unable to get net provider id".to_stri= ng())?.to_str().unwrap().to_string(); >>> + >>> + let svc_dir =3D format!("/run/service/vm-services/= instance/{provider_id}/data/service/spectrum-router"); >>> + let svc_status =3D 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 ro= uter 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=20 > this VM runs, the vmm for the provider VM would already be up? That=20 > would simplify the process and make assign-driver-router-iface=20 > unnecessary because there would be one place where we can add the interfa= ce. No, but you could s6-svwait in there, in the existing background block. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQQGoGac7QfI+H5ZtFCZddwkt31pFQUCaSsGsAAKCRCZddwkt31p FR89AP9V8izZWwQYuWD70ZMlXPt9DuvcdV+DREs+yaX0oooJEAD+OdQ9fV5BgS4e JYhyG23b0mNKDNwdIocMntRnN42b1wU= =GYBK -----END PGP SIGNATURE----- --=-=-=--