[pve-devel] [PATCH container 1/1] config: implement method to calculate derived properties from a config
Fiona Ebner
f.ebner at proxmox.com
Tue Feb 28 11:54:08 CET 2023
See the corresponding commit in guest-common for more information.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/PVE/LXC/Config.pm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index af25a96..b511c2b 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1732,4 +1732,16 @@ sub get_backup_volumes {
return $return_volumes;
}
+sub get_derived_property {
+ my ($class, $conf, $name) = @_;
+
+ if ($name eq 'max-cpu') {
+ return $conf->{cpulimit} || $conf->{cores} || 0;
+ } elsif ($name eq 'max-memory') {
+ return ($conf->{memory} || 512) * 1024 * 1024;
+ } else {
+ die "unknown derived property - $name\n";
+ }
+}
+
1;
--
2.30.2
More information about the pve-devel
mailing list