From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH ha-manager 1/1] resources: pve: avoid relying on internal configuration details
Date: Tue, 28 Feb 2023 11:54:10 +0100 [thread overview]
Message-ID: <20230228105410.51078-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20230228105410.51078-1-f.ebner@proxmox.com>
Instead, use the new get_derived_property() method to get the same
information in a way that is robust regarding changes in the
configuration structure.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/HA/Resources/PVECT.pm | 4 ++--
src/PVE/HA/Resources/PVEVM.pm | 7 ++-----
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm
index e77d98c..6e14692 100644
--- a/src/PVE/HA/Resources/PVECT.pm
+++ b/src/PVE/HA/Resources/PVECT.pm
@@ -158,8 +158,8 @@ sub get_static_stats {
my $conf = PVE::LXC::Config->load_config($id, $service_node);
return {
- maxcpu => $conf->{cpulimit} || $conf->{cores} || 0,
- maxmem => ($conf->{memory} || 512) * 1024 * 1024,
+ maxcpu => PVE::LXC::Config->get_derived_property($conf, 'max-cpu'),
+ maxmem => PVE::LXC::Config->get_derived_property($conf, 'max-memory'),
};
}
diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm
index f405d86..1543a2d 100644
--- a/src/PVE/HA/Resources/PVEVM.pm
+++ b/src/PVE/HA/Resources/PVEVM.pm
@@ -179,13 +179,10 @@ sub get_static_stats {
my ($class, $haenv, $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,
+ maxcpu => PVE::QemuConfig->get_derived_property($conf, 'max-cpu'),
+ maxmem => PVE::QemuConfig->get_derived_property($conf, 'max-memory'),
};
}
--
2.30.2
next prev parent reply other threads:[~2023-02-28 10:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 10:54 [pve-devel] [PATCH-SERIES guest-common/container/qemu-server/ha-manager] make HA manager not depend " Fiona Ebner
2023-02-28 10:54 ` [pve-devel] [PATCH guest-common 1/1] abstract config: add method to calculate derived properties from a config Fiona Ebner
2023-06-07 17:40 ` [pve-devel] applied: " Thomas Lamprecht
2023-02-28 10:54 ` [pve-devel] [PATCH container 1/1] config: implement " Fiona Ebner
2023-06-09 5:50 ` [pve-devel] applied: " Thomas Lamprecht
2023-02-28 10:54 ` [pve-devel] [PATCH qemu-server " Fiona Ebner
2023-06-08 15:59 ` [pve-devel] applied: " Thomas Lamprecht
2023-02-28 10:54 ` Fiona Ebner [this message]
2023-06-06 6:42 ` [pve-devel] [PATCH-SERIES guest-common/container/qemu-server/ha-manager] make HA manager not depend on internal configuration details Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230228105410.51078-5-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox