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 804851FF137 for ; Tue, 17 Feb 2026 15:16:13 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 223A438F6; Tue, 17 Feb 2026 15:15:22 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [RFC ha-manager 15/21] sim: hardware: rewrite set-static-stats Date: Tue, 17 Feb 2026 15:14:22 +0100 Message-ID: <20260217141437.584852-29-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260217141437.584852-1-d.kral@proxmox.com> References: <20260217141437.584852-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: 1771337678090 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.019 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: BKHNRKZZOHAKDVZS244W5WY247DUCCYU X-Message-ID-Hash: BKHNRKZZOHAKDVZS244W5WY247DUCCYU 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: From: Dominik Rusovac This decouples the stats input for the set-static-stats command. Using the old version one had to pass both, the maxcpu and maxmem stat, even if they wanted to set only one of the stats. To me, it appears to be more convenient to set one stat at a time instead of having to pass the value of the stat that is not changing alongside the value that should be changed. Signed-off-by: Dominik Rusovac Signed-off-by: Daniel Kral --- src/PVE/HA/Sim/Hardware.pm | 23 ++++++++++++++++------- src/PVE/HA/Sim/RTHardware.pm | 3 ++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm index 4d82e18c..ec135e09 100644 --- a/src/PVE/HA/Sim/Hardware.pm +++ b/src/PVE/HA/Sim/Hardware.pm @@ -743,7 +743,7 @@ sub get_cfs_state { # service stop # service lock/unlock [lockname] # service add [] [] -# service set-static-stats +# service set-static-stats # service delete sub sim_hardware_cmd { my ($self, $cmdstr, $logid) = @_; @@ -894,14 +894,23 @@ sub sim_hardware_cmd { ); } elsif ($action eq 'set-static-stats') { - die "sim_hardware_cmd: missing maxcpu for '$action' command" if !$params[0]; - die "sim_hardware_cmd: missing maxmem for '$action' command" if !$params[1]; + my ($target, $val) = ($params[0], $params[1]); - $self->set_static_service_stats( - $sid, - { maxcpu => 0.0 + $params[0], maxmem => int($params[1]) }, - ); + if (!$target) { + die "sim_hardware_cmd: missing target stat for '$action' command"; + } elsif ($target eq "maxcpu") { + die "sim_hardware_cmd: missing value for '$action $target' command" + if !$val; + $self->set_static_service_stats($sid, { $target => 0.0 + $val }); + } elsif ($target eq "maxmem") { + die "sim_hardware_cmd: missing value for '$action $target' command" + if !$val; + + $self->set_static_service_stats($sid, { $target => $val * 1024**2 }); + } else { + die "sim_hardware_cmd: unknown target stat '$target' for '$action' command"; + } } elsif ($action eq 'delete') { $self->delete_service($sid); diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm index 9a83d098..3fc52240 100644 --- a/src/PVE/HA/Sim/RTHardware.pm +++ b/src/PVE/HA/Sim/RTHardware.pm @@ -532,7 +532,8 @@ sub show_service_add_dialog { my $maxcpu = $cpu_count_spin->get_value(); my $maxmem = $memory_spin->get_value(); - $self->sim_hardware_cmd("service $sid set-static-stats $maxcpu $maxmem", 'command'); + $self->sim_hardware_cmd("service $sid set-static-stats maxcpu $maxcpu", 'command'); + $self->sim_hardware_cmd("service $sid set-static-stats maxmem $maxmem", 'command'); $self->add_service_to_gui($sid); } -- 2.47.3