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 5FC901FF0B7 for ; Fri, 13 Nov 2026 15:40:11 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E5AD6216E3; Fri, 13 Nov 2026 15:39:54 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-perl-rs v4 08/14] pve: pci: add host placements for the hostpci topology Date: Fri, 13 Nov 2026 15:39:24 +0100 Message-ID: <20261113143939.3012964-9-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261113143939.3012964-1-d.csapak@proxmox.com> References: <20261113143939.3012964-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.307 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: YX7GY6VM2J63PBI4QWQL5PI4GODNP7SV X-Message-ID-Hash: YX7GY6VM2J63PBI4QWQL5PI4GODNP7SV 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: For the 'numa' and 'host' hostpci topologies, the root ports and the addresses of the hostpcie devices depend on where the chosen devices sit on the host. qemu-server only chooses the devices right before generating their arguments, since choosing them reserves them, so the hardware config can't contain the placements. So add 'hostpcie_bus_devices', which takes the placements and returns the expander bridges, switches and root ports, and let 'addr' take them as an optional parameter. Existing callers don't have to change. Signed-off-by: Dominik Csapak --- pve-rs/src/bindings/pci/hardware_config.rs | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/pve-rs/src/bindings/pci/hardware_config.rs b/pve-rs/src/bindings/pci/hardware_config.rs index 777f18a..6b3cf1c 100644 --- a/pve-rs/src/bindings/pci/hardware_config.rs +++ b/pve-rs/src/bindings/pci/hardware_config.rs @@ -11,7 +11,9 @@ pub mod pve_rs_pci_hardware_config { use perlmod::Value; - use pve_qemu_server_pci::{HardwareConfigParams, LayoutError, address}; + use pve_qemu_server_pci::{ + HardwareConfigParams, HostpciePlacement, LayoutError, address, address_with_placements, + }; perlmod::declare_magic!(Box: &HardwareConfig as "PVE::RS::PCI::HardwareConfig"); @@ -40,11 +42,19 @@ pub mod pve_rs_pci_hardware_config { #[export] /// Method: Returns the PCI or PCIe address of the chosen device on the given machine if the /// device exists on the layout. + /// + /// With a hostpci topology other than 'flat', `hostpcie` devices need the host placements of + /// all `hostpcie` devices, see `hostpcie_bus_devices`. pub fn addr( #[try_from_ref] this: &HardwareConfig, id: &str, + placements: Option>, ) -> Result, LayoutError> { - match address(this, id) { + let addr = match placements { + Some(placements) => address_with_placements(this, id, &placements), + None => address(this, id), + }; + match addr { Ok(addr) => Ok(Some(addr.to_qemu_addr())), Err(LayoutError::NoAddressFound(_)) => Ok(None), Err(other) => Err(other), @@ -60,6 +70,19 @@ pub mod pve_rs_pci_hardware_config { pve_qemu_server_pci::pci_bus_devices(this) } + #[export] + /// Method: Get the `-device` arguments of the expander bridges, ports and switches of a hostpci + /// topology other than 'flat', for the given host placements of the `hostpcie` devices. + /// + /// They have to come after the `pci_bus_devices` and before the `hostpcie` devices. For the + /// 'flat' topology this is empty, since its root ports are part of `pci_bus_devices`. + pub fn hostpcie_bus_devices( + #[try_from_ref] this: &HardwareConfig, + placements: Vec, + ) -> Result, LayoutError> { + pve_qemu_server_pci::hostpcie_bus_devices(this, &placements) + } + #[export] /// Method: Whether the q35 chipset devices still have to be loaded from `pve-q35-4.0.cfg`. pub fn uses_q35_config_file(#[try_from_ref] this: &HardwareConfig) -> bool { -- 2.47.3