From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH proxmox-perl-rs 6/9] pve: pci bindings: add bindings for the `Machine` struct
Date: Tue, 22 Sep 2026 12:55:37 +0200 [thread overview]
Message-ID: <20260922105550.2084078-7-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260922105550.2084078-1-d.csapak@proxmox.com>
This is a better way to convey information necessary for some functions,
so make use of it in the bindings.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
pve-rs/Makefile | 1 +
pve-rs/src/bindings/pci/machine.rs | 45 ++++++++++++++++++++++++++++++
pve-rs/src/bindings/pci/mod.rs | 14 ++++------
3 files changed, 52 insertions(+), 8 deletions(-)
create mode 100644 pve-rs/src/bindings/pci/machine.rs
diff --git a/pve-rs/Makefile b/pve-rs/Makefile
index dbffb38..20a7d24 100644
--- a/pve-rs/Makefile
+++ b/pve-rs/Makefile
@@ -30,6 +30,7 @@ PERLMOD_PACKAGES := \
PVE::RS::NVML \
PVE::RS::OCI \
PVE::RS::PCI \
+ PVE::RS::PCI::Machine \
PVE::RS::OpenId \
PVE::RS::ResourceScheduling::Static \
PVE::RS::ResourceScheduling::Dynamic \
diff --git a/pve-rs/src/bindings/pci/machine.rs b/pve-rs/src/bindings/pci/machine.rs
new file mode 100644
index 0000000..d9efc32
--- /dev/null
+++ b/pve-rs/src/bindings/pci/machine.rs
@@ -0,0 +1,45 @@
+#[perlmod::package(name = "PVE::RS::PCI::Machine", lib = "pve_rs")]
+pub mod pve_rs_pci_machine {
+ //! The `PVE::RS::PCI::Machine` package.
+ //!
+ //! Provides bindings for the `Machine` struct of the [`pve-qemu-server-pci`] crate.
+
+ use std::sync::RwLock;
+
+ use anyhow::Error;
+
+ use perlmod::Value;
+
+ use pve_qemu_server_pci::Machine;
+
+ perlmod::declare_magic!(Box<MachineWrap>: &MachineWrap as "PVE::RS::PCI::Machine");
+
+ /// Wraps the `Machine` struct behind an RwLock since most accesses are reads.
+ pub struct MachineWrap {
+ /// test
+ pub inner: RwLock<Machine>,
+ }
+
+ #[export(raw_return)]
+ #[allow(clippy::too_many_arguments)]
+ /// Create a instance of the `MachineWrap` struct
+ pub fn new(
+ #[raw] class: Value,
+ arch: String,
+ q35: bool,
+ scsihw: Option<String>,
+ max_scsihw: u8,
+ legacy_igd: bool,
+ ostype: Option<String>,
+ major: u16,
+ minor: u16,
+ pve: Option<u16>,
+ ) -> Result<Value, Error> {
+ let machine = Machine::new(
+ &arch, q35, scsihw, max_scsihw, legacy_igd, ostype, major, minor, pve,
+ );
+ Ok(
+ perlmod::instantiate_magic!(&class, MAGIC => Box::new(MachineWrap { inner: RwLock::new(machine) })),
+ )
+ }
+}
diff --git a/pve-rs/src/bindings/pci/mod.rs b/pve-rs/src/bindings/pci/mod.rs
index 9b3ad9d..a036704 100644
--- a/pve-rs/src/bindings/pci/mod.rs
+++ b/pve-rs/src/bindings/pci/mod.rs
@@ -1,3 +1,5 @@
+pub(crate) mod machine;
+
#[perlmod::package(name = "PVE::RS::PCI", lib = "pve_rs")]
pub mod pve_rs_pci {
//! The `PVE::RS::PCI` package.
@@ -38,13 +40,9 @@ pub mod pve_rs_pci {
}
#[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)
+ /// Get the necessary PCI bridges for a guest from the given config.
+ pub fn get_pci_bridges(#[try_from_ref] machine: &MachineWrap) -> Vec<String> {
+ let machine = machine.inner.read().unwrap();
+ pve_qemu_server_pci::get_pci_bridges(&machine)
}
}
--
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 ` [PATCH proxmox-perl-rs 5/9] pve: add bindings for `pve-qemu-server-pci` crate Dominik Csapak
2026-09-22 10:55 ` Dominik Csapak [this message]
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-7-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