* [PATCH qemu-server] fix #3446: memory: suggest supported sizes for hotplug
@ 2026-11-24 13:00 Arkadiusz Miśkiewicz
0 siblings, 0 replies; only message in thread
From: Arkadiusz Miśkiewicz @ 2026-11-24 13:00 UTC (permalink / raw)
To: pve-devel; +Cc: Arkadiusz Miśkiewicz
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 <arekm@maven.pl>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 13:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:00 [PATCH qemu-server] fix #3446: memory: suggest supported sizes for hotplug Arkadiusz Miśkiewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox