From: Thomas Lamprecht Date: Thu, 17 Nov 2022 16:40:35 +0000 (+0100) Subject: memory hot plug: round down to nearest even phys-bits for heuristics X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=305e9cec5d74610650aa627176d048b1c7e44877;p=qemu-server.git memory hot plug: round down to nearest even phys-bits for heuristics Mira found out that 41 phys-bits the limit is pretty much the same as with 40, as such odd sizes are a bit unexpected anyway lets mask the LSB and use that as base, that way we're good again. Signed-off-by: Thomas Lamprecht --- diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm index 013917e..f8fc534 100644 --- a/PVE/QemuServer/Memory.pm +++ b/PVE/QemuServer/Memory.pm @@ -55,8 +55,10 @@ my sub get_max_mem { } } - # remove 20 bits to get MB and half that as QEMU needs some overhead - my $bits_to_max_mem = int(1 << ($bits - 21)); + $bits = $bits & ~1; # round down to nearest even as limit is lower with odd bit sizes + + # heuristic: remove 20 bits to get MB and half that as QEMU needs some overhead + my $bits_to_max_mem = int(1<<($bits - 21)); return $bits_to_max_mem > 4*1024*1024 ? 4*1024*1024 : $bits_to_max_mem; }