[pve-devel] [PATCH qemu-server] Use default values when memory is not set in vm.conf when migrating
Emmanuel Kasper
e.kasper at proxmox.com
Mon Jul 3 13:58:14 CEST 2017
This fixes a "Use of uninitialized value in multiplication (*) "
warning when doing a migration
---
PVE/QemuMigrate.pm | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index cb1639b..f995584 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -640,8 +640,9 @@ sub phase2 {
};
warn $@ if $@;
- #set cachesize 10% of the total memory
- my $cachesize = int($conf->{memory}*1048576/10);
+ # set cachesize to 10% of the total memory
+ my $memory = $conf->{memory} || $defaults->{memory};
+ my $cachesize = int($memory * 1048576 / 10);
$self->log('info', "set cachesize: $cachesize");
eval {
PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-cache-size", value => int($cachesize));
@@ -712,7 +713,7 @@ sub phase2 {
if ($stat->{status} eq 'completed') {
my $delay = time() - $start;
if ($delay > 0) {
- my $mbps = sprintf "%.2f", $conf->{memory}/$delay;
+ my $mbps = sprintf "%.2f", $memory / $delay;
my $downtime = $stat->{downtime} || 0;
$self->log('info', "migration speed: $mbps MB/s - downtime $downtime ms");
}
--
2.11.0
More information about the pve-devel
mailing list