From: Dominik Csapak <d.csapak@proxmox.com>
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 [thread overview]
Message-ID: <20260922105550.2084078-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260922105550.2084078-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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<String, Error> {
+ 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<String, Error> {
+ 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<String, Error> {
+ 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<u8> {
+ 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<String> {
+ pve_qemu_server_pci::get_pci_bridges(arch, q35, virtio_scsi_single, legacy_igd)
+ }
+}
--
2.47.3
next prev parent reply other threads:[~2026-09-22 10:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 10:55 [RFC proxmox-perl-rs/qemu-server/qemu-server-rs 0/9] pci-handling rewrite (part 1) Dominik Csapak
2026-09-22 10:55 ` [PATCH pve-qemu-server-rs 1/9] add pve-qemu-server-pci crate for guest PCI address generation Dominik Csapak
2026-09-22 10:55 ` [PATCH pve-qemu-server-rs 2/9] pci: add machine abstraction and PCI bridge generation Dominik Csapak
2026-09-22 10:55 ` [PATCH pve-qemu-server-rs 3/9] pci: layout: add v2 PCI and PCIe layouts Dominik Csapak
2026-09-22 10:55 ` [PATCH pve-qemu-server-rs 4/9] fixup! add pve-qemu-server-pci crate for guest PCI address generation Dominik Csapak
2026-09-22 10:55 ` Dominik Csapak [this message]
2026-09-22 10:55 ` [PATCH proxmox-perl-rs 6/9] pve: pci bindings: add bindings for the `Machine` struct Dominik Csapak
2026-09-22 10:55 ` [PATCH qemu-server 7/9] pci: use PVE::RS::PCI bindings Dominik Csapak
2026-09-22 10:55 ` [PATCH qemu-server 8/9] helpers: factor out the version parts parsing Dominik Csapak
2026-09-22 10:55 ` [PATCH qemu-server 9/9] pci: bridges: use the rust `Machine` struct to pass parameters Dominik Csapak
2026-09-22 11:06 ` [RFC proxmox-perl-rs/qemu-server/qemu-server-rs 0/9] pci-handling rewrite (part 1) 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=20260922105550.2084078-6-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