From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 19EBC1FF09B for ; Mon, 28 Sep 2026 16:06:57 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6276D21704; Mon, 28 Sep 2026 16:06:56 +0200 (CEST) Message-ID: <547b7ed3-544a-492d-84d2-3363f589349b@proxmox.com> Date: Mon, 28 Sep 2026 16:06:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH proxmox-perl-rs 5/9] pve: add bindings for `pve-qemu-server-pci` crate To: Elias Huhsovitz , pve-devel@lists.proxmox.com References: <20260922105550.2084078-1-d.csapak@proxmox.com> <20260922105550.2084078-6-d.csapak@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1790604411725 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.574 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: YLKBSKFYKVQ4OFCZXOXPKPIVTR6Q4QED X-Message-ID-Hash: YLKBSKFYKVQ4OFCZXOXPKPIVTR6Q4QED 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: On 9/28/26 2:56 PM, Elias Huhsovitz wrote: > I feel like this patch (5/9) and the next patch (6/9) could have been > the same commit. Since here we already use > crate::bindings::pci::machine::pve_rs_pci_machine::MachineWrap, which > gets introduced in the subsequent patch. > yeah, i guess i'll don't split the patch in my next version, especially since i've already added quite a bunch of other things locally and removed most of the `print_*` functions anyway.... > On Tue Sep 22, 2026 at 12:55 PM CEST, Dominik Csapak wrote: >> 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; > > this crate here doesnt exist yet. > >> + >> + #[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) >> + } >> +} >