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 13F1C1FF0AF for ; Thu, 22 Oct 2026 11:22:38 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id AFA85214D3; Thu, 22 Oct 2026 11:22:37 +0200 (CEST) From: Elias Huhsovitz To: pve-devel@lists.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 Message-ID: <20261022092227.58871-3-e.huhsovitz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261022092227.58871-1-e.huhsovitz@proxmox.com> References: <20261022092227.58871-1-e.huhsovitz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792660953388 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.519 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) 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: BPP7EOPNYZUXRR6QYJH7M5CWE6U36DRM X-Message-ID-Hash: BPP7EOPNYZUXRR6QYJH7M5CWE6U36DRM X-MailFrom: e.huhsovitz@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 CC: Elias Huhsovitz X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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