[PATCH ha-manager v4 05/28] sim: hardware: pass correct types for static stats

Daniel Kral
2026-04-02T12:48:16Z

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

CRM expects f64 for cpu-related values and usize for mem-related values.
Hence, pass doubles for the former and ints for the latter.

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 | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 474cee16..cfcd7ab1 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -488,9 +488,9 @@ sub new {
|| die "Copy failed: $!\n";
} else {
my $cstatus = {
- node1 => { power => 'off', network => 'off', maxcpu => 24, maxmem => 131072 },
- node2 => { power => 'off', network => 'off', maxcpu => 24, maxmem => 131072 },
- node3 => { power => 'off', network => 'off', maxcpu => 24, maxmem => 131072 },
+ node1 => { power => 'off', network => 'off', maxcpu => 24.0, maxmem => 131072 },
+ node2 => { power => 'off', network => 'off', maxcpu => 24.0, maxmem => 131072 },
+ node3 => { power => 'off', network => 'off', maxcpu => 24.0, maxmem => 131072 },
};
$self->write_hardware_status_nolock($cstatus);
}
@@ -507,7 +507,7 @@ sub new {
copy("$testdir/static_service_stats", "$statusdir/static_service_stats");
} else {
my $services = $self->read_service_config();
- my $stats = { map { $_ => { maxcpu => 4, maxmem => 4096 } } keys %$services };
+ my $stats = { map { $_ => { maxcpu => 4.0, maxmem => 4096 } } keys %$services };
$self->write_static_service_stats($stats);
}

@@ -883,7 +883,7 @@ sub sim_hardware_cmd {

$self->set_static_service_stats(
$sid,
- { maxcpu => $params[0], maxmem => $params[1] },
+ { maxcpu => 0.0 + $params[0], maxmem => int($params[1]) },
);

} elsif ($action eq 'manual-migrate') {
--
2.47.3