]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer/Memory.pm
memory hot plug: round down to nearest even phys-bits for heuristics
[qemu-server.git] / 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;
 }