arch => {
optional => 1,
type => 'string',
- enum => ['amd64', 'i386', 'arm64', 'armhf'],
+ enum => ['amd64', 'i386', 'arm64', 'armhf', 'riscv32', 'riscv64'],
description => "OS architecture type.",
default => 'amd64',
},
description => "Apply rate limiting to the interface",
optional => 1,
},
+ # TODO: Rename this option and the qemu-server one to `link-down` for PVE 8.0
+ link_down => {
+ type => 'boolean',
+ description => 'Whether this interface should be disconnected (like pulling the plug).',
+ optional => 1,
+ },
};
PVE::JSONSchema::register_format('pve-lxc-network', $netconf_desc);
}
# END JSON config code
+# takes a max memory value as KiB and returns an tuple with max and high values
+sub calculate_memory_constraints {
+ my ($memory) = @_;
+
+ return if !defined($memory);
+
+ # cgroup memory usage is limited by the hard 'max' limit (OOM-killer enforced) and the soft
+ # 'high' limit (cgroup processes get throttled and put under heavy reclaim pressure).
+ my $memory_max = int($memory * 1024 * 1024);
+ # Set the high to 1016/1024 (~99.2%) of the 'max' hard limit clamped to 128 MiB max, to scale
+ # it for the lower range while having a decent 2^x based rest for 2^y memory configs.
+ my $memory_high = $memory >= 16 * 1024 ? int(($memory - 128) * 1024 * 1024) : int($memory * 1024 * 1016);
+
+ return ($memory_max, $memory_high);
+}
+
my $LXC_FASTPLUG_OPTIONS= {
'description' => 1,
'onboot' => 1,
# memory (iow. memory+swap). This means we have to change them together.
my $hotplug_memory_done;
my $hotplug_memory = sub {
- my ($wanted_memory, $wanted_swap) = @_;
+ my ($new_memory, $new_swap) = @_;
- $wanted_memory = int($wanted_memory * 1024 * 1024) if defined($wanted_memory);
- $wanted_swap = int($wanted_swap * 1024 * 1024) if defined($wanted_swap);
- $cgroup->change_memory_limit($wanted_memory, $wanted_swap);
+ ($new_memory, my $new_memory_high) = calculate_memory_constraints($new_memory);
+ $new_swap = int($new_swap * 1024 * 1024) if defined($new_swap);
+ $cgroup->change_memory_limit($new_memory, $new_swap, $new_memory_high);
$hotplug_memory_done = 1;
};
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;