[PATCH ha-manager v4 07/28] sim: hardware: fix static stats guard

Daniel Kral
2026-04-02T12:47:59Z

From: Dominik Rusovac <d.rusovac@proxmox.com>

While falsy, values of 0 or 0.0 are valid stats. Hence, use
'defined'-check to avoid skipping falsy static service stats.

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
changes v3 -> v4:
- none

src/PVE/HA/Sim/Hardware.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 026be6f8..afdb7b5f 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -202,11 +202,11 @@ sub set_static_service_stats {

my $stats = $self->read_static_service_stats();

- if (my $memory = $new_stats->{maxmem}) {
+ if (defined(my $memory = $new_stats->{maxmem})) {
$stats->{$sid}->{maxmem} = $memory;
}

- if (my $cpu = $new_stats->{maxcpu}) {
+ if (defined(my $cpu = $new_stats->{maxcpu})) {
$stats->{$sid}->{maxcpu} = $cpu;
}

--
2.47.3