public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
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	[thread overview]
Message-ID: <20261113143939.3012964-9-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261113143939.3012964-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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>: &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<Vec<HostpciePlacement>>,
     ) -> Result<Option<String>, 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<HostpciePlacement>,
+    ) -> Result<Vec<String>, 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





  parent reply	other threads:[~2026-11-13 14:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 14:39 [PATCH manager/proxmox-perl-rs/qemu-server/qemu-server-rs v4 00/14] pci-handling rewrite Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 01/14] add pve-qemu-server-pci crate for guest PCI address generation Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 02/14] pci: legacy: generate pci bridges Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 03/14] pci: legacy: generate q35 chipset devices and hostpcie root ports Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 04/14] pci: layout: add grouped PCI and PCIe layouts Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 05/14] pci: bus: add buses for numa expander bridges and pcie switches Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-qemu-server-rs v4 06/14] pci: topology: place hostpcie devices like on the host Dominik Csapak
2026-11-13 14:39 ` [PATCH proxmox-perl-rs v4 07/14] pve: add bindings for `pve-qemu-server-pci` crate Dominik Csapak
2026-11-13 14:39 ` Dominik Csapak [this message]
2026-11-13 14:39 ` [PATCH qemu-server v4 09/14] pci: use PVE::RS::PCI bindings for addresses and bus devices Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 10/14] tree-wide: use HardwareConfig for the machine version checks Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 11/14] cfg2cmd: q35: generate chipset devices with machine version 11.1+pve1 Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 12/14] machine: add 'pci-layout' option Dominik Csapak
2026-11-13 14:39 ` [PATCH qemu-server v4 13/14] machine: add 'pci-topology' option Dominik Csapak
2026-11-13 14:39 ` [PATCH pve-manager v4 14/14] ui: qemu machine: don't lose pci options on edit cycle Dominik Csapak

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=20261113143939.3012964-9-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal