From 8b1accf7ce147c61ffa14297b579cd3faa325208 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 19 Dec 2012 07:24:39 +0100 Subject: [PATCH] add shares property for auto-ballooning Also allow to set 'balloon: 0' to disable the ballon driver. --- PVE/QemuServer.pm | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index a9dd08ce..17f359a6 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -206,8 +206,16 @@ my $confdesc = { balloon => { optional => 1, type => 'integer', - description => "Amount of target RAM for the VM in MB.", - minimum => 16, + description => "Amount of target RAM for the VM in MB. Using zero disables the ballon driver.", + minimum => 0, + }, + shares => { + optional => 1, + type => 'integer', + description => "Amount of memory shares for auto-ballooning. The larger the number is, the more memory this VM gets. Number is relative to weights of all other running VMs. Using zero disables auto-ballooning", + minimum => 0, + maximum => 50000, + default => 1000, }, keyboard => { optional => 1, @@ -1954,6 +1962,11 @@ sub vmstatus { $d->{name} = $conf->{name} || "VM $vmid"; $d->{maxmem} = $conf->{memory} ? $conf->{memory}*(1024*1024) : 0; + if ($conf->{balloon}) { + $d->{balloon_min} = $conf->{balloon}; + $d->{shares} = $conf->{shares} || 1000; + } + $d->{uptime} = 0; $d->{cpu} = 0; $d->{mem} = 0; @@ -2980,8 +2993,11 @@ sub vm_start { $capabilities->{capability} = "xbzrle"; $capabilities->{state} = JSON::true; eval { PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-capabilities", capabilities => [$capabilities]); }; - } elsif ($conf->{balloon}) { - vm_balloonset($vmid, $conf->{balloon}); + } + + # fixme: how do we handle that on migration? + if ($conf->{balloon}) { + vm_mon_cmd($vmid, "balloon", value => $conf->{balloon}*1024*1024); vm_mon_cmd($vmid, 'qom-set', path => "machine/peripheral/balloon0", property => "stats-polling-interval", @@ -3416,12 +3432,6 @@ sub print_pci_addr { } -sub vm_balloonset { - my ($vmid, $value) = @_; - - vm_mon_cmd($vmid, "balloon", value => $value*1024*1024); -} - # vzdump restore implementaion sub archive_read_firstfile {