]> git.proxmox.com Git - qemu-server.git/commitdiff
memory hot plug: round down to nearest even phys-bits for heuristics
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Nov 2022 16:40:35 +0000 (17:40 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Nov 2022 16:45:59 +0000 (17:45 +0100)
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 <t.lamprecht@proxmox.com>
PVE/QemuServer/Memory.pm

index 013917e79ca26c327971bc0bc38850e30358664f..f8fc534098d628813a0862f7209ee1d7d1251d66 100644 (file)
@@ -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;
 }