all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Elias Huhsovitz <e.huhsovitz@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Elias Huhsovitz <e.huhsovitz@proxmox.com>
Subject: [PATCH proxmox-perl-rs v3 2/3] pve: cpu: add PVE::RS::CPU::Bind perl bindings
Date: Thu, 22 Oct 2026 11:22:24 +0200	[thread overview]
Message-ID: <20261022092227.58871-3-e.huhsovitz@proxmox.com> (raw)
In-Reply-To: <20261022092227.58871-1-e.huhsovitz@proxmox.com>

Expose the pve-qemu-server-cpu crate to Perl as PVE::RS::CPU::Bind. Two
functions are exported, matching the crate's public API:

* validate_binding(mode, sockets, cores, cfg)
* bind_vcpus(mode, cfg, cpuinfo_json)

Add pve-qemu-server-cpu as a path dependency of pve-rs. The crate is
packaged as librust-pve-qemu-server-cpu-dev.

Signed-off-by: Elias Huhsovitz <e.huhsovitz@proxmox.com>
---
 pve-rs/Cargo.toml               |  1 +
 pve-rs/Makefile                 |  1 +
 pve-rs/src/bindings/cpu/bind.rs | 40 +++++++++++++++++++++++++++++++++
 pve-rs/src/bindings/cpu/mod.rs  |  2 ++
 pve-rs/src/bindings/mod.rs      |  3 +++
 5 files changed, 47 insertions(+)
 create mode 100644 pve-rs/src/bindings/cpu/bind.rs
 create mode 100644 pve-rs/src/bindings/cpu/mod.rs

diff --git a/pve-rs/Cargo.toml b/pve-rs/Cargo.toml
index 0c4a47e..282266d 100644
--- a/pve-rs/Cargo.toml
+++ b/pve-rs/Cargo.toml
@@ -53,6 +53,7 @@ proxmox-time = "2"
 proxmox-ve-config = { version = "0.10.4", features = [ "frr" ] }
 proxmox-wireguard = { version = "0.1.2" }
 pve-qemu-server-pci = "0.1"
+pve-qemu-server-cpu = "0.1"
 
 # [patch.crates-io]
 # pbs-api-types = { path = "../../proxmox/pbs-api-types" }
diff --git a/pve-rs/Makefile b/pve-rs/Makefile
index c239f2a..077ad4a 100644
--- a/pve-rs/Makefile
+++ b/pve-rs/Makefile
@@ -30,6 +30,7 @@ PERLMOD_PACKAGES := \
 	  PVE::RS::NVML \
 	  PVE::RS::OCI \
 	  PVE::RS::PCI::HardwareConfig \
+	  PVE::RS::CPU::Bind \
 	  PVE::RS::OpenId \
 	  PVE::RS::ResourceScheduling::Static \
 	  PVE::RS::ResourceScheduling::Dynamic \
diff --git a/pve-rs/src/bindings/cpu/bind.rs b/pve-rs/src/bindings/cpu/bind.rs
new file mode 100644
index 0000000..864c56d
--- /dev/null
+++ b/pve-rs/src/bindings/cpu/bind.rs
@@ -0,0 +1,40 @@
+#[perlmod::package(name = "PVE::RS::CPU::Bind", lib = "pve_rs")]
+pub mod pve_rs_cpu_bind {
+    //! `PVE::RS::CPU::Bind` package.
+    //!
+    //! Exposes the vCPU binding entry points.
+    //! from [`pve_qemu_server_cpu`].
+
+    use anyhow::{Error, format_err};
+
+    /// Validate a `cpu-bind-map` for the given mode before the VM starts.
+    ///
+    /// `binding_info` is the raw config value (`cpu-bind-map`,
+    /// `cpu-binding-list`, `numa-binding-map`, or `numa-binding-list`,
+    /// depending on `mode`). Returns `Ok(())` on success; on error, the
+    /// returned string is suitable for `die` in Perl.
+    #[export]
+    pub fn validate_binding(
+        mode: &str,
+        sockets: u32,
+        cores: u32,
+        binding_cfg: &str,
+    ) -> Result<(), Error> {
+        pve_qemu_server_cpu::validate_binding(mode, sockets, cores, binding_cfg)
+            .map_err(|e| format_err!("{e}"))
+    }
+
+    /// Apply the binding to a running VM.
+    ///
+    /// `cpuinfo_json` must be the JSON-encoded `query-cpus-fast` QMP
+    /// response.
+    #[export]
+    pub fn bind_vcpus(
+        mode: &str,
+        binding_cfg: &str,
+        cpuinfo_json: &str,
+    ) -> Result<(), Error> {
+        pve_qemu_server_cpu::bind_vcpus(mode, binding_cfg, cpuinfo_json)
+            .map_err(|e| format_err!("{e}"))
+    }
+}
diff --git a/pve-rs/src/bindings/cpu/mod.rs b/pve-rs/src/bindings/cpu/mod.rs
new file mode 100644
index 0000000..3dd4427
--- /dev/null
+++ b/pve-rs/src/bindings/cpu/mod.rs
@@ -0,0 +1,2 @@
+mod bind;
+pub use bind::pve_rs_cpu_bind;
diff --git a/pve-rs/src/bindings/mod.rs b/pve-rs/src/bindings/mod.rs
index b26c602..e9473a8 100644
--- a/pve-rs/src/bindings/mod.rs
+++ b/pve-rs/src/bindings/mod.rs
@@ -9,6 +9,9 @@ pub use oci::pve_rs_oci;
 mod pci;
 pub use pci::pve_rs_pci_hardware_config;
 
+mod cpu;
+pub use cpu::pve_rs_cpu_bind;
+
 pub mod resource_scheduling;
 
 mod tfa;
-- 
2.47.3





  parent reply	other threads:[~2026-10-22  9:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  9:22 [PATCH proxmox-perl-rs/qemu-server/qemu-server-rs v3 0/3] vCPU binding for qemu guests Elias Huhsovitz
2026-10-22  9:22 ` [PATCH qemu-server-rs v3 1/3] cpu: add pve-qemu-server-cpu crate for vCPU binding Elias Huhsovitz
2026-10-22  9:22 ` Elias Huhsovitz [this message]
2026-10-22  9:22 ` [PATCH qemu-server v3 3/3] cpu: add CPU binding Elias Huhsovitz

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=20261022092227.58871-3-e.huhsovitz@proxmox.com \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal