From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id BE6151FF066 for ; Tue, 24 Nov 2026 14:39:19 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 83F5221571; Tue, 24 Nov 2026 14:39:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maven.pl; s=maven; t=1795525260; x=1796130060; darn=lists.proxmox.com; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=NjtsS8TlY6gZADa3scud2TrhEeI+pRR3Zcd/yjxvxds=; b=lYGg/2G2CGqSpXquWb22OLMc6s9kf1DsW1sGJKar21Kx8UdQiaXWhzjYv4D5Qh+bBu Xa57FpN1oKCrms+M++86vS1Z7/2SwFw0OCJ1PpdmBavGBh8MtOSirt69QsiNYtiiqaTD FHkyH7Ct3u2jLFRCmXMScak7h+Mmc8WMdvfEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795525260; x=1796130060; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=NjtsS8TlY6gZADa3scud2TrhEeI+pRR3Zcd/yjxvxds=; b=YtiqykGWVdb87jkl0OO97A2+mfR33P/HlxnLqR7pjmQkKXs+fAj0FGCeVNwtUfkqsk TYnw6maC7XRwcgVD2lsR3I+lcUs8jCpeLSy02GaGaESknPxt0QYeWdGFV0G7hJ3hwDMr 42mGTerAc4I2jrMgjQTs5i35qspMgbqcjJcklln2kOz1UniiIQaAvO6TOPkmkO8Mql9F Y/BRDI/FfOuMQymnXGBtGbyZ1IoQFW0IFLMO72c94CexH6mC52QEWCx3SpV5vrgg3UKs bnkkQ7FXJa5IQCd/RXGii+Pb1ro3ynnKN0fU8G65CWVO2vKe0em5y9jdhGS9s9nC+Rtu GU5Q== X-Gm-Message-State: APuU4Z/+NgLnLPJWyfQk1CI82re7qDIgh03Qppx9qf8wGTgCPp13xEPY oN1d0Y6RPiDlTeRpOqUwgWvu2VLbAFflrkRrs//hUFsIFsZyIomqzldy1ca0ISxf1Jt0HanxB6j MD05+Sv4= X-Gm-Gg: AZFdTZc/1Mr9Ho8rHotZvG997WqyxHRsbE7vK3Gtuf1X0HWJV/F3p+UDBda0BzlQXyB ed2G4Y/hHqQzzbe6hGV9lCUmd1cxiIdVEX6o7WFmbwN6G/p80Z/vDGswBB7eKfMr66MZloJ6D3I i3hSUURcHDvf1HlL5Z3JkIAY+Tg9Lqv9/wCJr2UgnivuKsgim8cKy5Yt8hXj0K4YebtLNsG7iZo f/J42loudKQe0MHKPMJpA7CEOmlzgY0AZOObS8Qstgi5RXX5NbLzBjo8BSIKES6JznUGYA6hYVO 3IN+/SFtM3gUUwmxa1qoKqDT+8C7RHsdhCeSv4wsg9LGgyC6oKLK43RRqvzhGf8+89cxDWstxdy 4e/U5LYlkPQmsOS8l+ufT4wG65o8qMAVnny3lhe8flthgOq46VD05nJEx1M1YykQVHJcxaoNj7x wZbzfz90bLtQFABhDLnihdsU73V5+fHns91DKzA07RH6Us/W81dl/6BMG70N7Wt4VCGgJTIM6km WW7mWFm3R6ZcoRIchBUJw56tYG4BIIOxfG2EWbeR9NWVQ8ai8vecEX2JR9wi1a2rm5e6Mk/HuIz 6vfHsVC25iCVrZHwU58JP8DIStzlWjGf61xEr/ZPTlMr4EgY5Q== X-Received: by 2002:a17:906:c14b:b0:c35:babe:ab44 with SMTP id a640c23a62f3a-c513a1e0076mr1447420866b.0.1795525259954; Tue, 24 Nov 2026 05:00:59 -0800 (PST) From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server] fix #3446: memory: suggest supported sizes for hotplug Date: Tue, 24 Nov 2026 14:00:56 +0100 Message-ID: <20261124130056.2101759-1-arekm@maven.pl> X-Mailer: git-send-email 2.56.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record X-MailFrom: arekm@maven.pl X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation Message-ID-Hash: BUWSBXFE5EMFTXU7Q4BLSCUKO6PBSKEN X-Message-ID-Hash: BUWSBXFE5EMFTXU7Q4BLSCUKO6PBSKEN X-Mailman-Approved-At: Tue, 24 Nov 2026 14:39:15 +0100 CC: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: With memory hotplug, the memory of a VM is made up of static memory plus DIMMs of growing size: 32 DIMMs of 512 MiB, then 32 of 1 GiB, 32 of 2 GiB and so on. Only the totals this layout reaches can be used. For any other size the error claimed that the size has to be aligned to the current DIMM size, which is misleading: 65536 is aligned to 2048, but it is still rejected with 2 GiB DIMMs. Users had to guess a working value. Name the closest supported sizes below and above the requested one instead, for example 64512 or 66560 for 65536 MiB. The size above is left out if it exceeds the maximum memory of the VM or needs more DIMMs than there are slots. A size that needs more DIMMs than there are slots was not rejected at all so far, QEMU then failed to start with "no free slots available". It now gets the same error and suggestion. Signed-off-by: Arkadiusz Miƛkiewicz --- This is the stop-gap from comment 21 on the bug (attachment 1906), rebased onto current master and simplified: both candidate values are already known where the error is raised, so the DIMM layout is not walked a second time. Tested with 'make -C src/test' (passes, with pve-guest-common from git master, as the packaged one is older than required). The four new cfg2cmd tests fail without the change. Also checked against a copy of foreach_dimm(): for every rejected size up to 140000 MiB and samples up to 4 TiB, without hugepages and with 1 GiB hugepages on 1, 2 and 4 sockets, both candidate sizes are reachable by the DIMM layout. src/PVE/QemuServer/Memory.pm | 16 +++++++++++++--- .../memory-hotplug-unsupported-size-max-mem.conf | 10 ++++++++++ ...mory-hotplug-unsupported-size-slots-full.conf | 10 ++++++++++ .../memory-hotplug-unsupported-size-slots.conf | 10 ++++++++++ .../cfg2cmd/memory-hotplug-unsupported-size.conf | 11 +++++++++++ 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/test/cfg2cmd/memory-hotplug-unsupported-size-max-mem.conf create mode 100644 src/test/cfg2cmd/memory-hotplug-unsupported-size-slots-full.conf create mode 100644 src/test/cfg2cmd/memory-hotplug-unsupported-size-slots.conf create mode 100644 src/test/cfg2cmd/memory-hotplug-unsupported-size.conf diff --git a/src/PVE/QemuServer/Memory.pm b/src/PVE/QemuServer/Memory.pm index 2dbf2dc7..fb63be51 100644 --- a/src/PVE/QemuServer/Memory.pm +++ b/src/PVE/QemuServer/Memory.pm @@ -74,6 +74,7 @@ sub parse_numa { } my $STATICMEM = 1024; +my $DIMM_SLOTS = 255; our $memory_fmt = { current => { @@ -387,7 +388,7 @@ sub config { if ($conf->{hugepages} && $conf->{hugepages} == 1024); die "minimum memory must be ${static_memory}MB\n" if ($memory < $static_memory); - push @$cmd, '-m', "size=${static_memory},slots=255,maxmem=${MAX_MEM}M"; + push @$cmd, '-m', "size=${static_memory},slots=${DIMM_SLOTS},maxmem=${MAX_MEM}M"; } else { @@ -496,8 +497,17 @@ sub config { push @$cmd, "-object", $mem_object; push @$cmd, "-device", "pc-dimm,id=$name,memdev=mem-$name,node=$numanode"; - die "memory size ($memory) must be aligned to $dimm_size for hotplugging\n" - if $current_size > $memory; + # the DIMM layout has one DIMM more than QEMU gets slots + my ($dimm_id) = $name =~ m/^dimm(\d+)$/; + + if ($current_size > $memory || $dimm_id >= $DIMM_SLOTS) { + # the size before this DIMM is the closest valid one below $memory + my $suggestion = $current_size - $dimm_size; + $suggestion .= " or $current_size" + if $dimm_id < $DIMM_SLOTS && $current_size <= get_max_mem($conf); + die "memory size ($memory) is not supported for hotplugging" + . " - try $suggestion\n"; + } }, ); } diff --git a/src/test/cfg2cmd/memory-hotplug-unsupported-size-max-mem.conf b/src/test/cfg2cmd/memory-hotplug-unsupported-size-max-mem.conf new file mode 100644 index 00000000..c3b29ffe --- /dev/null +++ b/src/test/cfg2cmd/memory-hotplug-unsupported-size-max-mem.conf @@ -0,0 +1,10 @@ +# TEST: memory hotplug with an unsupported size, next supported size above max mem +# EXPECT_ERROR: memory size (520000) is not supported for hotplugging - try 508928 +cores: 2 +cpu: kvm64,phys-bits=40 +hotplug: memory +memory: 520000 +numa: 1 +ostype: l26 +smbios1: uuid=7b10d7af-b932-4c66-b2c3-3996152ec465 +vmgenid: c773c261-d800-4348-9f5d-167fadd53cf8 diff --git a/src/test/cfg2cmd/memory-hotplug-unsupported-size-slots-full.conf b/src/test/cfg2cmd/memory-hotplug-unsupported-size-slots-full.conf new file mode 100644 index 00000000..5c6852e7 --- /dev/null +++ b/src/test/cfg2cmd/memory-hotplug-unsupported-size-slots-full.conf @@ -0,0 +1,10 @@ +# TEST: memory hotplug with a size that needs more DIMMs than there are slots +# EXPECT_ERROR: memory size (4194304) is not supported for hotplugging - try 4113408 +cores: 2 +cpu: kvm64,phys-bits=46 +hotplug: memory +memory: 4194304 +numa: 1 +ostype: l26 +smbios1: uuid=7b10d7af-b932-4c66-b2c3-3996152ec465 +vmgenid: c773c261-d800-4348-9f5d-167fadd53cf8 diff --git a/src/test/cfg2cmd/memory-hotplug-unsupported-size-slots.conf b/src/test/cfg2cmd/memory-hotplug-unsupported-size-slots.conf new file mode 100644 index 00000000..4ac7111c --- /dev/null +++ b/src/test/cfg2cmd/memory-hotplug-unsupported-size-slots.conf @@ -0,0 +1,10 @@ +# TEST: memory hotplug with an unsupported size, next supported size needs a 256th DIMM +# EXPECT_ERROR: memory size (4150000) is not supported for hotplugging - try 4113408 +cores: 2 +cpu: kvm64,phys-bits=46 +hotplug: memory +memory: 4150000 +numa: 1 +ostype: l26 +smbios1: uuid=7b10d7af-b932-4c66-b2c3-3996152ec465 +vmgenid: c773c261-d800-4348-9f5d-167fadd53cf8 diff --git a/src/test/cfg2cmd/memory-hotplug-unsupported-size.conf b/src/test/cfg2cmd/memory-hotplug-unsupported-size.conf new file mode 100644 index 00000000..3bc68962 --- /dev/null +++ b/src/test/cfg2cmd/memory-hotplug-unsupported-size.conf @@ -0,0 +1,11 @@ +# TEST: memory hotplug with a size the DIMM layout cannot reach +# EXPECT_ERROR: memory size (65536) is not supported for hotplugging - try 64512 or 66560 +cores: 2 +memory: 65536 +name: simple +numa: 1 +ostype: l26 +smbios1: uuid=7b10d7af-b932-4c66-b2c3-3996152ec465 +sockets: 2 +vmgenid: c773c261-d800-4348-9f5d-167fadd53cf8 +hotplug: memory -- 2.56.1