[pve-devel] [PATCH v2 qemu-server 4/9] config: memory: add 'max' option

Alexandre Derumier aderumier at odiso.com
Wed Jan 4 07:42:58 CET 2023


max can be multiple of 64GB only,
The dimm size is compute from the max memory

we can have 64 slots:

64GB = 64 slots x 1GB
128GB = 64 slots x 2GB
..
4TB = 64 slots x 64GB

Also, with numa, we need to share slot between (up to 8) sockets.

64 is a multiple of 8,

64GB = 8 sockets * 8 slots * 1GB
128GB = 8 sockets * 8 slots * 2GB
...

and with virtio-mem,
we can have 32000 blocks of 2M minimum

64GB = 32000 * 2MB

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer/Memory.pm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm
index e9c0115..1c4f356 100644
--- a/PVE/QemuServer/Memory.pm
+++ b/PVE/QemuServer/Memory.pm
@@ -5,6 +5,7 @@ use warnings;
 
 use PVE::Tools qw(run_command lock_file lock_file_full file_read_firstline dir_glob_foreach);
 use PVE::Exception qw(raise raise_param_exc);
+use PVE::GuestHelpers qw(safe_string_ne safe_num_ne safe_boolean_ne);
 
 use PVE::QemuServer;
 use PVE::QemuServer::Monitor qw(mon_cmd);
@@ -25,7 +26,14 @@ my $memory_fmt = {
 	optional => 1,
 	minimum => 16,
 	default => 512,
-    }
+    },
+    max => {
+	type => 'integer',
+	optional => 1,
+	type => 'integer',
+	minimum => 65536,
+	maximum => 4194304
+    },
 };
 
 sub print_memory {
@@ -43,6 +51,9 @@ sub parse_memory {
 
     $res = eval { PVE::JSONSchema::parse_property_string($memory_fmt, $value) };
     die $@ if $@;
+
+    die "max memory need to be a multiple of 64GB" if $res->{max} && $res->{max} % 65536 != 0;
+
     return $res;
 }
 
@@ -223,6 +234,11 @@ sub qemu_memory_hotplug {
     my $oldmem = parse_memory($conf->{memory});
     my $newmem = parse_memory($value);
 
+    # skip non hotpluggable value
+    if (safe_num_ne($newmem->{max}, $oldmem->{max})) {
+	die "skip\n";
+    }
+
     my $memory = $oldmem->{current};
     $value = $newmem->{current};
 
-- 
2.30.2





More information about the pve-devel mailing list