[pve-devel] [PATCH ha-manager 02/11] resources: add get_static_stats() method

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Nov 15 14:28:24 CET 2022


Am 10/11/2022 um 15:37 schrieb Fiona Ebner:
> to be used for static resource scheduling.
> 
> In container's vmstatus(), the 'cores' option takes precedence over
> the 'cpulimit' one, but it felt more accurate to prefer 'cpulimit'
> here.
> 
> Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
>  src/PVE/HA/Resources.pm       |  5 +++++
>  src/PVE/HA/Resources/PVECT.pm | 11 +++++++++++
>  src/PVE/HA/Resources/PVEVM.pm | 14 ++++++++++++++
>  3 files changed, 30 insertions(+)
> 
> diff --git a/src/PVE/HA/Resources.pm b/src/PVE/HA/Resources.pm
> index 835c314..f7eaff2 100644
> --- a/src/PVE/HA/Resources.pm
> +++ b/src/PVE/HA/Resources.pm
> @@ -161,6 +161,11 @@ sub remove_locks {
>      die "implement in subclass";
>  }
>  
> +sub get_static_stats {
> +    my ($class, $id, $service_node) = @_;
> +
> +    die "implement in subclass";
> +}
>  
>  # package PVE::HA::Resources::IPAddr;
>  
> diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm
> index 015faf3..8209d9c 100644
> --- a/src/PVE/HA/Resources/PVECT.pm
> +++ b/src/PVE/HA/Resources/PVECT.pm
> @@ -150,4 +150,15 @@ sub remove_locks {
>      return undef;
>  }
>  
> +sub get_static_stats {
> +    my ($class, $id, $service_node) = @_;
> +
> +    my $conf = PVE::LXC::Config->load_config($id, $service_node);
> +
> +    return {
> +	maxcpu => $conf->{cpulimit} || $conf->{cores} || 0,
> +	maxmem => ($conf->{memory} || 512) * 1024 * 1024,

nit, would prefer one of snake or kebab case for those keys (no hard feeling on which
one, should just be consistent within similar (i.e., the stats) stuff.

> +    };
> +}
> +
>  1;
> diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm
> index 58c83e0..85196ed 100644
> --- a/src/PVE/HA/Resources/PVEVM.pm
> +++ b/src/PVE/HA/Resources/PVEVM.pm
> @@ -173,4 +173,18 @@ sub remove_locks {
>      return undef;
>  }
>  
> +sub get_static_stats {
> +    my ($class, $id, $service_node) = @_;
> +
> +    my $conf = PVE::QemuConfig->load_config($id, $service_node);

maybe it could be worth to use the CFS_IPC_GET_GUEST_CONFIG_PROPERTY successor that
Dominik developed for the tags stuff once applied for this, can be still switched too
transparently, if this shows to be a bottleneck in the future though, so just mentioning
for completeness sake.

> +    my $defaults = PVE::QemuServer::load_defaults();
> +
> +    my $cpus = ($conf->{sockets} || $defaults->{sockets}) * ($conf->{cores} || $defaults->{cores});
> +
> +    return {
> +	maxcpu => $conf->{vcpus} || $cpus,
> +	maxmem => ($conf->{memory} || $defaults->{memory}) * 1024 * 1024,

same here. As this is just internal we can also adapt it later though..

> +    };
> +}
> +
>  1;






More information about the pve-devel mailing list