From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 49FA091782 for ; Thu, 2 Feb 2023 12:04:00 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0927CB11B for ; Thu, 2 Feb 2023 12:04:00 +0100 (CET) Received: from bastionodiso.odiso.net (bastionodiso.odiso.net [IPv6:2a0a:1580:2000::2d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 2 Feb 2023 12:03:57 +0100 (CET) Received: from kvmformation3.odiso.net (formationkvm3.odiso.net [10.3.94.12]) by bastionodiso.odiso.net (Postfix) with ESMTP id 12FC682AD; Thu, 2 Feb 2023 12:03:50 +0100 (CET) Received: by kvmformation3.odiso.net (Postfix, from userid 0) id 11D5D22A2BF; Thu, 2 Feb 2023 12:03:50 +0100 (CET) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Thu, 2 Feb 2023 12:03:37 +0100 Message-Id: <20230202110344.840195-7-aderumier@odiso.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230202110344.840195-1-aderumier@odiso.com> References: <20230202110344.840195-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% HEADER_FROM_DIFFERENT_DOMAINS 0.25 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemuserver.pm, memory.pm] Subject: [pve-devel] [PATCH v3 qemu-server 06/13] config: memory: add 'max' option X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Feb 2023 11:04:00 -0000 max can be multiple of 64GiB only, The dimm size is compute from the max memory we can have 64 slots: 64GiB = 64 slots x 1GiB 128GiB = 64 slots x 2GiB .. 4TiB = 64 slots x 64GiB Also, with numa, we need to share slot between (up to 8) sockets. 64 is a multiple of 8, 64GiB = 8 sockets * 8 slots * 1GiB 128GiB = 8 sockets * 8 slots * 2GiB ... and with virtio-mem, we can have 32000 blocks of 2MiB minimum 64GB = 32000 * 2MiB Signed-off-by: Alexandre Derumier --- PVE/QemuServer.pm | 4 ++-- PVE/QemuServer/Memory.pm | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 9db1d8e..1f73605 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -5042,7 +5042,7 @@ sub vmconfig_hotplug_pending { vm_deviceunplug($vmid, $conf, $opt); vmconfig_delete_or_detach_drive($vmid, $storecfg, $conf, $opt, $force); } elsif ($opt =~ m/^memory$/) { - die "skip\n" if !$hotplug_features->{memory}; + die "skip\n" if !PVE::QemuServer::Memory::can_hotplug($hotplug_features->{memory}, $conf); PVE::QemuServer::Memory::qemu_memory_hotplug($vmid, $conf); } elsif ($opt eq 'cpuunits') { $cgroup->change_cpu_shares(undef); @@ -5118,7 +5118,7 @@ sub vmconfig_hotplug_pending { vmconfig_update_disk($storecfg, $conf, $hotplug_features->{disk}, $vmid, $opt, $value, $arch, $machine_type); } elsif ($opt =~ m/^memory$/) { #dimms - die "skip\n" if !$hotplug_features->{memory}; + die "skip\n" if !PVE::QemuServer::Memory::can_hotplug($hotplug_features->{memory}, $conf, $value); $value = PVE::QemuServer::Memory::qemu_memory_hotplug($vmid, $conf, $value); } elsif ($opt eq 'cpuunits') { my $new_cpuunits = PVE::CGroup::clamp_cpu_shares($conf->{pending}->{$opt}); #clamp diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm index 7079907..a46b504 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); use PVE::QemuServer; use PVE::QemuServer::Monitor qw(mon_cmd); @@ -24,9 +26,23 @@ our $memory_fmt = { default_key => 1, minimum => 16, default => 512, + }, + max => { + 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) = @_; + + die "max memory need to be a multiple of 64GiB\n" if $max && $max % 65536 != 0; +} + sub print_memory { my $memory = shift; @@ -311,6 +327,19 @@ sub qemu_memory_hotplug { return $conf->{memory}; } +sub can_hotplug { + my ($hotplug, $conf, $value) = @_; + + return if !$hotplug || !$value; + + my $oldmem = parse_memory($conf->{memory}); + my $newmem = parse_memory($value); + + return if safe_num_ne($newmem->{max}, $oldmem->{max}); + + return 1; +} + sub qemu_dimm_list { my ($vmid) = @_; -- 2.30.2