[pve-devel] [PATCH v2 qemu-server 4/6] fix: qemu: uninitialized value in multiplication

Oguz Bektas o.bektas at proxmox.com
Mon Nov 18 15:41:13 CET 2019


From: Alwin Antreich <a.antreich at proxmox.com>

A generated VM with default values does not set the memory key in the
configuration. Hence the size of the state file for a suspend had only
the default size of the state itself and not in addition twice the
configured memory.

The patch uses the static defaults from the JSON schema if the memory
key is not set.

Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
(cherry picked from commit 22ea69ca65b14bf0caf64dd0daf5c6bff675edf8)
Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 PVE/QemuConfig.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
index 8fae4fc..84d601a 100644
--- a/PVE/QemuConfig.pm
+++ b/PVE/QemuConfig.pm
@@ -137,12 +137,14 @@ sub __snapshot_save_vmstate {
 	$target = $shared // $local // 'local';
     }
 
+    my $defaults = PVE::QemuServer::load_defaults();
+    my $mem_size = $conf->{memory} // $defaults->{memory};
     my $driver_state_size = 500; # assume 500MB is enough to safe all driver state;
     # our savevm-start does live-save of the memory until the space left in the
     # volume is just enough for the remaining memory content + internal state
     # then it stops the vm and copies the rest so we reserve twice the
     # memory content + state to minimize vm downtime
-    my $size = $conf->{memory}*2 + $driver_state_size;
+    my $size = $mem_size*2 + $driver_state_size;
     my $scfg = PVE::Storage::storage_config($storecfg, $target);
 
     my $name = "vm-$vmid-state-$snapname";
-- 
2.20.1




More information about the pve-devel mailing list