From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id CE1FA1FF144 for ; Tue, 24 Mar 2026 19:31:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D4B7319E9C; Tue, 24 Mar 2026 19:31:14 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [PATCH perl-rs v2 14/40] pve-rs: resource-scheduling: static: replace deprecated usage structs Date: Tue, 24 Mar 2026 19:29:58 +0100 Message-ID: <20260324183029.1274972-15-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260324183029.1274972-1-d.kral@proxmox.com> References: <20260324183029.1274972-1-d.kral@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774376988480 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.057 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: GVLEKRE5TTINYX6B5ITIKPB3GQWSTH5D X-Message-ID-Hash: GVLEKRE5TTINYX6B5ITIKPB3GQWSTH5D X-MailFrom: d.kral@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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The StaticServiceUsage is marked as deprecated in proxmox-resource-scheduling now to make the crate independent of the specific usage structs and the deserialization of these. Therefore, define the same struct in the pve_static bindings module. Though this is technically a Rust API break, the Perl bindings do not have the concept of structs, which are serialized as Perl hashes. Signed-off-by: Daniel Kral --- changes v1 -> v2: - new! Move towards handling (de)serialization in pve-rs and having the generic impls in the proxmox-resource-scheduling crate. .../resource_scheduling/pve_static.rs | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/pve-rs/src/bindings/resource_scheduling/pve_static.rs b/pve-rs/src/bindings/resource_scheduling/pve_static.rs index 3d9f142..e2756db 100644 --- a/pve-rs/src/bindings/resource_scheduling/pve_static.rs +++ b/pve-rs/src/bindings/resource_scheduling/pve_static.rs @@ -9,10 +9,11 @@ pub mod pve_rs_resource_scheduling_static { use std::sync::Mutex; use anyhow::Error; + use serde::{Deserialize, Serialize}; use perlmod::Value; use proxmox_resource_scheduling::node::NodeStats; - use proxmox_resource_scheduling::pve_static::StaticServiceUsage; + use proxmox_resource_scheduling::resource::ResourceStats; use proxmox_resource_scheduling::usage::Usage; use crate::bindings::resource_scheduling::{ @@ -26,7 +27,28 @@ pub mod pve_rs_resource_scheduling_static { inner: Mutex, } - type StaticResource = PveResource; + #[derive(Clone, Copy, Debug, Serialize, Deserialize)] + #[serde(rename_all = "kebab-case")] + /// Static usage stats of a resource. + pub struct StaticResourceStats { + /// Number of assigned CPUs or CPU limit. + pub maxcpu: f64, + /// Maximum assigned memory in bytes. + pub maxmem: usize, + } + + impl From for ResourceStats { + fn from(stats: StaticResourceStats) -> Self { + Self { + cpu: stats.maxcpu, + maxcpu: stats.maxcpu, + mem: stats.maxmem, + maxmem: stats.maxmem, + } + } + } + + type StaticResource = PveResource; /// Class method: Create a new [`Scheduler`] instance. /// @@ -113,13 +135,13 @@ pub mod pve_rs_resource_scheduling_static { #[try_from_ref] this: &Scheduler, nodename: &str, sid: &str, - service_usage: StaticServiceUsage, + service_stats: StaticResourceStats, ) -> Result<(), Error> { let mut usage = this.inner.lock().unwrap(); // TODO Only for backwards compatibility, can be removed with a proper version bump #[allow(deprecated)] - usage.add_resource_usage_to_node(nodename, sid, service_usage.into()) + usage.add_resource_usage_to_node(nodename, sid, service_stats.into()) } /// Method: Remove service `sid` and its usage from all assigned nodes. @@ -138,7 +160,7 @@ pub mod pve_rs_resource_scheduling_static { #[export] pub fn score_nodes_to_start_service( #[try_from_ref] this: &Scheduler, - service_stats: StaticServiceUsage, + service_stats: StaticResourceStats, ) -> Result, Error> { let usage = this.inner.lock().unwrap(); -- 2.47.3