[pve-devel] [PATCH v2 qemu-server 3/9] memory: add get_static_mem
Fiona Ebner
f.ebner at proxmox.com
Tue Jan 24 14:04:58 CET 2023
Am 04.01.23 um 07:42 schrieb Alexandre Derumier:
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
> PVE/QemuServer/Memory.pm | 43 +++++++++++++++++++++-------------------
> 1 file changed, 23 insertions(+), 20 deletions(-)
>
> diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm
> index 59e51c8..e9c0115 100644
> --- a/PVE/QemuServer/Memory.pm
> +++ b/PVE/QemuServer/Memory.pm
> @@ -15,7 +15,6 @@ get_current_memory
> );
>
> my $MAX_NUMA = 8;
> -my $STATICMEM = 1024;
>
> my $memory_fmt = {
> current => {
> @@ -47,6 +46,26 @@ sub parse_memory {
> return $res;
> }
>
> +my sub get_static_mem {
> + my ($conf, $defaults) = @_;
Rather than passing in $defaults, you can pass in $sockets. I think all
callers already have that available.
> +
> + my $sockets = $conf->{sockets} || $defaults->{sockets};
> + my $hotplug_features = PVE::QemuServer::parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
Could also rather be passed-in as a parameter, maybe even as a simple
boolean to test for directly instead of $hotplug_features. In the longer
term, it'd be nice to get rid of the cylic usage of PVE::QemuServer and
having such calls deep in private methods doesn't help there.
> +
> + my $static_memory = 0;
> + my $memory = parse_memory($conf->{memory});
> +
> + if ($hotplug_features->{memory}) {
> + #legacy
> + $static_memory = 1024;
> + $static_memory = $static_memory * $sockets if ($conf->{hugepages} && $conf->{hugepages} == 1024);
> + } else {
> + $static_memory = $memory->{current};
> + }
> +
> + return $static_memory;
> +}
> +
> my $_host_bits;
> my sub get_host_phys_address_bits {
> return $_host_bits if defined($_host_bits);
More information about the pve-devel
mailing list