[pve-devel] [PATCH 1/2] added maxmemory config and pass this to qemu -m option with a default of 10 slots

Alexandre Derumier aderumier at odiso.com
Wed Jul 16 16:07:30 CEST 2014


From: Stefan Priebe <s.priebe at profihost.ag>

Signed-off-by: Stefan Priebe <s.priebe at profihost.ag>
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index abed0c1..b94e976 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -307,6 +307,12 @@ EODESC
 	minimum => 1,
 	default => 1,
     },
+    maxmemory => {
+	optional => 1,
+	type => 'integer',
+	description => "Maximum memory in GB for hotplug incl. memory setting.",
+	minimum => 1,
+    },
     acpi => {
 	optional => 1,
 	type => 'boolean',
@@ -2763,7 +2769,13 @@ sub config_to_command {
 	push @$devices, '-device', print_drivedevice_full($storecfg, $conf, $vmid, $drive, $bridges);
     });
 
-    push @$cmd, '-m', $conf->{memory} || $defaults->{memory};
+    $conf->{memory} ||= $defaults->{memory};
+
+    if ($conf->{maxmemory} && $conf->{maxmemory}*1024 > $conf->{memory}) {
+	push @$cmd, '-m', "size=".$conf->{memory}.",slots=10,maxmem=".$conf->{maxmemory}."G";
+    } else {
+	push @$cmd, '-m', $conf->{memory};
+    }
 
     for (my $i = 0; $i < $MAX_NETS; $i++) {
          next if !$conf->{"net$i"};
-- 
1.7.10.4




More information about the pve-devel mailing list