From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 4E11B1FF0C0 for ; Wed, 18 Nov 2026 16:28:59 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 8B77521728; Wed, 18 Nov 2026 16:28:29 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v5 10/13] pve-qemu-pci: bus: add buses for numa expander bridges and pcie switches Date: Wed, 18 Nov 2026 16:27:52 +0100 Message-ID: <20261118152803.3843758-11-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118152803.3843758-1-d.csapak@proxmox.com> References: <20261118152803.3843758-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.284 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: BPWCTIQZJ7XCNHLY5AA4MUZXMVCO53BU X-Message-ID-Hash: BPWCTIQZJ7XCNHLY5AA4MUZXMVCO53BU X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: These are needed to place hostpcie devices like on the host. `bridge_model` now also returns the models for them and for root ports, so the code placing the devices can look them up. Signed-off-by: Dominik Csapak --- pve-qemu-rs/pve-qemu-pci/src/types/bus.rs | 37 +++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/pve-qemu-rs/pve-qemu-pci/src/types/bus.rs b/pve-qemu-rs/pve-qemu-pci/src/types/bus.rs index 052ef008..602c88a9 100644 --- a/pve-qemu-rs/pve-qemu-pci/src/types/bus.rs +++ b/pve-qemu-rs/pve-qemu-pci/src/types/bus.rs @@ -84,17 +84,35 @@ pub enum Bus { Sys(u8), /// One of the bridges PVE adds per device kind, see [`PveBridge`]. Pve { kind: PveBridge, index: u8 }, + /// Root bus of the PCIe expander bridge for a guest NUMA node. + Numa(u8), + /// The bus behind the port of a replicated PCIe switch, only holds its + /// upstream port. + SwitchUplink(u8), + /// The bus behind the upstream port of a replicated PCIe switch, holds its + /// downstream ports. + Switch(u8), + /// The bus behind the downstream switch port for `hostpcie`. + SwitchPort(u8), } type BusConstructor = fn(u8) -> Bus; impl Bus { /// The QEMU device model needed to create this bus below `parent`, or - /// `None` if the bus is not created by a bridge device. + /// `None` for root buses. pub fn bridge_model(self, parent: Bus) -> Option<&'static str> { match self { + Bus::Pcie(_) => None, #[expect(deprecated)] - Bus::Pcie(_) | Bus::RootPort(_) | Bus::LegacyRootPort(_) => None, + Bus::RootPort(_) | Bus::LegacyRootPort(_) => Some("pcie-root-port"), + Bus::Numa(_) => Some("pxb-pcie"), + Bus::SwitchUplink(_) => Some(match parent { + Bus::Switch(_) => "xio3130-downstream", + _ => "pcie-root-port", + }), + Bus::Switch(_) => Some("x3130-upstream"), + Bus::SwitchPort(_) => Some("xio3130-downstream"), Bus::Pcidmi => Some("i82801b11-bridge"), Bus::Sys(_) | Bus::Pci(_) | Bus::Pve { .. } => Some(match parent { #[expect(deprecated)] @@ -118,6 +136,10 @@ impl std::fmt::Display for Bus { Bus::Pve { kind, index } => { write!(f, "pve.{kind}{index}") } + Bus::Numa(i) => write!(f, "pve.numa{i}"), + Bus::SwitchUplink(i) => write!(f, "pve.switch-uplink{i}"), + Bus::Switch(i) => write!(f, "pve.switch{i}"), + Bus::SwitchPort(i) => write!(f, "pve.switch-port{i}"), } } } @@ -127,7 +149,8 @@ impl std::str::FromStr for Bus { fn from_str(s: &str) -> Result { // NOTE: the prefixes here must be checked before the generic 'pve.' - // one below, which would otherwise swallow them. + // one below, which would otherwise swallow them. Also 'pve.switch' has to + // come after the longer 'pve.switch-' prefixes. const PREFIXES: &[(&str, BusConstructor)] = &[ ("pci.", Bus::Pci), ("pcie.", Bus::Pcie), @@ -135,6 +158,10 @@ impl std::str::FromStr for Bus { #[expect(deprecated)] ("ich9-pcie-port-", Bus::LegacyRootPort), ("pve.sys", Bus::Sys), + ("pve.numa", Bus::Numa), + ("pve.switch-uplink", Bus::SwitchUplink), + ("pve.switch-port", Bus::SwitchPort), + ("pve.switch", Bus::Switch), ]; if s == "pcidmi" { @@ -194,5 +221,9 @@ mod test { #[expect(deprecated)] test(Bus::LegacyRootPort(99)); test(Bus::Sys(99)); + test(Bus::Numa(7)); + test(Bus::SwitchUplink(99)); + test(Bus::Switch(99)); + test(Bus::SwitchPort(99)); } } -- 2.47.3