[pve-devel] [PATCH v4 qemu-server 08/16] config: memory: add 'max' option
Fiona Ebner
f.ebner at proxmox.com
Wed Feb 22 16:18:34 CET 2023
Am 13.02.23 um 13:00 schrieb Alexandre Derumier:
> diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm
> index 32fbdc5..deeb88f 100644
> --- a/PVE/QemuServer/Memory.pm
> +++ b/PVE/QemuServer/Memory.pm
> @@ -3,8 +3,10 @@ package PVE::QemuServer::Memory;
> use strict;
> use warnings;
>
> +use PVE::JSONSchema;
> use PVE::Tools qw(run_command lock_file lock_file_full file_read_firstline dir_glob_foreach);
> use PVE::Exception qw(raise raise_param_exc);
> +use PVE::GuestHelpers qw(safe_string_ne safe_num_ne safe_boolean_ne);
Stlye nit: pre-existing, but now it's even less sorted alphabetically.
Also, you don't use safe_string_ne so no need to import (and
safe_boolean_ne should be imported by the patch that uses it).
>
> use PVE::QemuServer;
> use PVE::QemuServer::Monitor qw(mon_cmd);
> @@ -25,8 +27,26 @@ our $memory_fmt = {
> minimum => 16,
> default => 512,
> },
> + max => {
Really could use a description, so that users know that it's used for
hotplug.
> + type => 'integer',
> + optional => 1,
> + minimum => 65536,
> + maximum => 4194304,
> + format => 'pve-qm-memory-max',
> + },
> };
>
> +PVE::JSONSchema::register_format('pve-qm-memory-max', \&verify_qm_memory_max);
> +sub verify_qm_memory_max {
> + my ($max, $noerr) = @_;
> +
> + return if $noerr;
$noerr only switches if the function should die upon error or return
undef upon error. But if there is no error, you always need to return
the verified value, i.e. $max.
> +
> + die "max memory need to be a multiple of 64GiB\n" if $max && $max % 65536 != 0;
> +
> + return $max
> +}
> +
> sub print_memory {
> my $memory = shift;
>
More information about the pve-devel
mailing list