so callers can avoid the overhead from load_config() if they already have the required information.
Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> --- src/PVE/HA/Resources.pm | 2 +- src/PVE/HA/Resources/PVECT.pm | 4 ++-- src/PVE/HA/Resources/PVEVM.pm | 5 +++-- src/PVE/HA/Sim/Resources.pm | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/PVE/HA/Resources.pm b/src/PVE/HA/Resources.pm index 7ba90f6..ee8de52 100644 --- a/src/PVE/HA/Resources.pm +++ b/src/PVE/HA/Resources.pm @@ -162,7 +162,7 @@ sub remove_locks { } sub get_static_stats { - my ($class, $haenv, $id, $service_node) = @_; + my ($class, $haenv, $id, $service_node, $cache) = @_; die "implement in subclass"; } diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm index e77d98c..c10d024 100644 --- a/src/PVE/HA/Resources/PVECT.pm +++ b/src/PVE/HA/Resources/PVECT.pm @@ -153,9 +153,9 @@ sub remove_locks { } sub get_static_stats { - my ($class, $haenv, $id, $service_node) = @_; + my ($class, $haenv, $id, $service_node, $cache) = @_; - my $conf = PVE::LXC::Config->load_config($id, $service_node); + my $conf = $cache->{$id} ||= PVE::LXC::Config->load_config($id, $service_node); return { maxcpu => $conf->{cpulimit} || $conf->{cores} || 0, diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm index f405d86..ca7fbc4 100644 --- a/src/PVE/HA/Resources/PVEVM.pm +++ b/src/PVE/HA/Resources/PVEVM.pm @@ -176,9 +176,10 @@ sub remove_locks { } sub get_static_stats { - my ($class, $haenv, $id, $service_node) = @_; + my ($class, $haenv, $id, $service_node, $cache) = @_; + + my $conf = $cache->{$id} ||= PVE::QemuConfig->load_config($id, $service_node); - my $conf = PVE::QemuConfig->load_config($id, $service_node); my $defaults = PVE::QemuServer::load_defaults(); my $cpus = ($conf->{sockets} || $defaults->{sockets}) * ($conf->{cores} || $defaults->{cores}); diff --git a/src/PVE/HA/Sim/Resources.pm b/src/PVE/HA/Sim/Resources.pm index e6e1853..999a77a 100644 --- a/src/PVE/HA/Sim/Resources.pm +++ b/src/PVE/HA/Sim/Resources.pm @@ -140,7 +140,7 @@ sub remove_locks { } sub get_static_stats { - my ($class, $haenv, $id, $service_node) = @_; + my ($class, $haenv, $id, $service_node, $cache) = @_; my $sid = $class->type() . ":$id"; my $hardware = $haenv->hardware(); -- 2.30.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel