[pve-devel] [PATCH v4 qemu-server 09/16] memory: get_max_mem: use config memory max

Fiona Ebner f.ebner at proxmox.com
Wed Feb 22 16:19:01 CET 2023


Am 13.02.23 um 13:00 schrieb Alexandre Derumier:
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 9b80da1..6627910 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -32,7 +32,7 @@ use PVE::QemuServer::Drive;
>  use PVE::QemuServer::ImportDisk;
>  use PVE::QemuServer::Monitor qw(mon_cmd);
>  use PVE::QemuServer::Machine;
> -use PVE::QemuServer::Memory qw(get_current_memory);
> +use PVE::QemuServer::Memory qw(get_current_memory parse_memory get_host_max_mem);
>  use PVE::QemuMigrate;
>  use PVE::RPCEnvironment;
>  use PVE::AccessControl;
> @@ -476,6 +476,26 @@ my $create_disks = sub {
>      return ($vollist, $res);
>  };
>  
> +my $check_memory_param = sub {
> +    my ($conf, $param) = @_;
> +

Nit: Could also die if current > max.

> +    my $mem = parse_memory($param->{memory});
> +    my $host_max_mem = get_host_max_mem($conf);
> +
> +    die "memory max can't be bigger than supported cpu architecture $host_max_mem MiB\n"
> +	if $mem->{max} && $mem->{max} > $host_max_mem;
> +
> +    if ($param->{memory} || defined($param->{balloon})) {
> +
> +	my $memory = $param->{memory} || $conf->{pending}->{memory} || $conf->{memory};
> +	my $maxmem = get_current_memory($memory);
> +	my $balloon = defined($param->{balloon}) ? $param->{balloon} : $conf->{pending}->{balloon} || $conf->{balloon};
> +
> +	die "balloon value too large (must be smaller than assigned memory)\n"
> +	    if $balloon && $balloon > $maxmem;
> +    }
> +};
> +
>  my $check_cpu_model_access = sub {
>      my ($rpcenv, $authuser, $new, $existing) = @_;
>  





More information about the pve-devel mailing list