public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Elias Huhsovitz <e.huhsovitz@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-perl-rs 5/9] pve: add bindings for `pve-qemu-server-pci` crate
Date: Mon, 28 Sep 2026 16:06:51 +0200	[thread overview]
Message-ID: <547b7ed3-544a-492d-84d2-3363f589349b@proxmox.com> (raw)
In-Reply-To: <DLQYSHZRGI16.2WG8A7Y8Q4AOH@proxmox.com>



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 <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;
> 
> 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<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)
>> +    }
>> +}
> 





  reply	other threads:[~2026-09-28 14:06 UTC|newest]

Thread overview: 19+ 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-28 12:53   ` Elias Huhsovitz
2026-09-28 14:00     ` 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-28 12:55   ` Elias Huhsovitz
2026-09-28 14:04     ` 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-28 12:55   ` Elias Huhsovitz
2026-09-28 14:05     ` 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 ` [PATCH proxmox-perl-rs 5/9] pve: add bindings for `pve-qemu-server-pci` crate Dominik Csapak
2026-09-28 12:56   ` Elias Huhsovitz
2026-09-28 14:06     ` 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=547b7ed3-544a-492d-84d2-3363f589349b@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=e.huhsovitz@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