[pve-devel] [PATCH ha-manager 02/11] resources: add get_static_stats() method
Fiona Ebner
f.ebner at proxmox.com
Thu Nov 10 15:37:50 CET 2022
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,
+ };
+}
+
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);
+ 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,
+ };
+}
+
1;
--
2.30.2
More information about the pve-devel
mailing list