get_derived_property(...) is called in the semi-hot path of the HA Manager's static load scheduler to retrieve the static stats of each VM. As the defaults are only needed in certain cases and for a very small subset of properties in the VM config, get those separately when needed.
Signed-off-by: Daniel Kral <[email protected]> --- changes since v1: - none src/PVE/QemuConfig.pm | 8 +++----- src/PVE/QemuServer.pm | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/PVE/QemuConfig.pm b/src/PVE/QemuConfig.pm index bb469197..ad6ce6b0 100644 --- a/src/PVE/QemuConfig.pm +++ b/src/PVE/QemuConfig.pm @@ -582,12 +582,10 @@ sub load_current_config { sub get_derived_property { my ($class, $conf, $name) = @_; - my $defaults = PVE::QemuServer::load_defaults(); - if ($name eq 'max-cpu') { - my $cpus = - ($conf->{sockets} || $defaults->{sockets}) * ($conf->{cores} || $defaults->{cores}); - return $conf->{vcpus} || $cpus; + my $sockets = $conf->{sockets} || PVE::QemuServer::get_default_property_value('sockets'); + my $cores = $conf->{cores} || PVE::QemuServer::get_default_property_value('cores'); + return $conf->{vcpus} || ($sockets * $cores); } elsif ($name eq 'max-memory') { # current usage maximum, not maximum hotpluggable return get_current_memory($conf->{memory}) * 1024 * 1024; } else { diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index df2476aa..8b8e8338 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -2126,6 +2126,12 @@ sub write_vm_config { return $raw; } +sub get_default_property_value { + my ($name) = @_; + + return $confdesc->{$name}->{default}; +} + sub load_defaults { my $res = {}; -- 2.47.3 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
