[pve-devel] [PATCH 6/6] live migration: reduce sleep when remaining memory is low
Alexandre Derumier
aderumier at odiso.com
Tue Aug 14 07:43:12 CEST 2012
Reduce sleep to 0.3s when remaining memory is lower than twice the average transfert in 1 iteration.
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuMigrate.pm | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index ee57cc2..bd461a1 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -330,8 +330,13 @@ sub phase2 {
my $merr = $@;
my $lstat = 0;
+ my $sleep = 2;
+ my $i = 0;
while (1) {
- sleep (2);
+ $i++;
+ my $avglstat = $lstat/$i if $lstat;
+
+ sleep ($sleep);
my $stat = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "query-migrate");
if ($stat->{status} =~ m/^(active|completed|failed|cancelled)$/im) {
$merr = undef;
@@ -357,13 +362,15 @@ sub phase2 {
my $trans = $stat->{ram}->{transferred} || 0;
my $rem = $stat->{ram}->{remaining} || 0;
my $total = $stat->{ram}->{total} || 0;
+ #reduce sleep if remainig memory if lower than twice the everage transfert
+ $sleep = "0.3"if $rem < ($avglstat*2);
$self->log('info', "migration status: $stat->{status} (transferred ${trans}, " .
"remaining ${rem}), total ${total})");
}
$lstat = $stat->{ram}->{transferred};
-
+
} else {
die $merr if $merr;
die "unable to parse migration status '$stat->{status}' - aborting\n";
--
1.7.2.5
More information about the pve-devel
mailing list