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 4A5E61FF0AA for ; Tue, 22 Sep 2026 12:56:07 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 50677215AD; Tue, 22 Sep 2026 12:55:56 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-perl-rs 5/9] pve: add bindings for `pve-qemu-server-pci` crate Date: Tue, 22 Sep 2026 12:55:36 +0200 Message-ID: <20260922105550.2084078-6-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260922105550.2084078-1-d.csapak@proxmox.com> References: <20260922105550.2084078-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.542 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) KAM_MAILER 2 Automated Mailer Tag Left in Email 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: YSTHRAP2IUH46TULGTAGUPVAESUHZPPF X-Message-ID-Hash: YSTHRAP2IUH46TULGTAGUPVAESUHZPPF 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 provide bindings for using the rust pci code in PVE's qemu-server perl code. For now a very limited set of functions that live in rust. Signed-off-by: Dominik Csapak --- pve-rs/Cargo.toml | 1 + pve-rs/Makefile | 1 + pve-rs/src/bindings/mod.rs | 3 ++ pve-rs/src/bindings/pci/mod.rs | 50 ++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 pve-rs/src/bindings/pci/mod.rs diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml index 5ae9082..0c4a47e 100644 --- a/pve-rs/Cargo.toml +++ b/pve-rs/Cargo.toml @@ -52,6 +52,7 @@ proxmox-tfa = { version = "6.0.3", features = ["api"] } proxmox-time = "2" proxmox-ve-config = { version = "0.10.4", features = [ "frr" ] } proxmox-wireguard = { version = "0.1.2" } +pve-qemu-server-pci = "0.1" # [patch.crates-io] # pbs-api-types = { path = "../../proxmox/pbs-api-types" } diff --git a/pve-rs/Makefile b/pve-rs/Makefile index bb1cd2d..dbffb38 100644 --- a/pve-rs/Makefile +++ b/pve-rs/Makefile @@ -29,6 +29,7 @@ PERLMOD_PACKAGES := \ PVE::RS::Firewall::SDN \ PVE::RS::NVML \ PVE::RS::OCI \ + PVE::RS::PCI \ PVE::RS::OpenId \ PVE::RS::ResourceScheduling::Static \ PVE::RS::ResourceScheduling::Dynamic \ diff --git a/pve-rs/src/bindings/mod.rs b/pve-rs/src/bindings/mod.rs index f922982..2d88580 100644 --- a/pve-rs/src/bindings/mod.rs +++ b/pve-rs/src/bindings/mod.rs @@ -6,6 +6,9 @@ pub use nvml::pve_rs_nvml; mod oci; pub use oci::pve_rs_oci; +mod pci; +pub use pci::pve_rs_pci; + pub mod resource_scheduling; mod tfa; diff --git a/pve-rs/src/bindings/pci/mod.rs b/pve-rs/src/bindings/pci/mod.rs new file mode 100644 index 0000000..9b3ad9d --- /dev/null +++ b/pve-rs/src/bindings/pci/mod.rs @@ -0,0 +1,50 @@ +#[perlmod::package(name = "PVE::RS::PCI", lib = "pve_rs")] +pub mod pve_rs_pci { + //! The `PVE::RS::PCI` package. + //! + //! Provides bindings for the [`pve-qemu-server-pci`] crate. + + use anyhow::{Error, format_err}; + + pub use pve_qemu_server_pci::Machine; + + use crate::bindings::pci::machine::pve_rs_pci_machine::MachineWrap; + + #[export] + /// Prints the PCI address for a guest from the given ID and architecture. + pub fn print_pci_addr(id: &str, arch: &str) -> Result { + pve_qemu_server_pci::print_pci_addr(id, arch) + .map_err(|err| format_err!("can't find pci address for {id}: {:?}", err)) + } + + #[export] + /// Prints the PCIe address for a guest from the given ID. + pub fn print_pcie_addr(id: &str) -> Result { + pve_qemu_server_pci::print_pcie_addr(id) + .map_err(|err| format_err!("can't find pcie address for {id}: {:?}", err)) + } + + #[export] + /// Prints the PCIe root port for a guest from the given index. + pub fn print_pcie_root_port(i: u8) -> Result { + pve_qemu_server_pci::print_pcie_root_port(i) + .map_err(|err| format_err!("can't find pcie root port {i}: {:?}", err)) + } + + #[export] + /// Get PCI bridge number the given device sits on (if it exists) + pub fn get_pci_bridge_for_device(id: &str) -> Option { + pve_qemu_server_pci::get_pci_bridge_for_device(id) + } + + #[export] + /// Get the necessary PCI bridges for a guest from the given options. + pub fn get_pci_bridges( + arch: &str, + q35: bool, + virtio_scsi_single: bool, + legacy_igd: bool, + ) -> Vec { + pve_qemu_server_pci::get_pci_bridges(arch, q35, virtio_scsi_single, legacy_igd) + } +} -- 2.47.3