[pve-devel] [PATCH 1/2] implement dynamic migration_downtime

Alexandre Derumier aderumier at odiso.com
Sun Dec 30 19:02:59 CET 2012


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

changelog:

- increment counter also if remaining memory equal 0 (qemu 1.4 migration code)
- only increment coutner and set down_time if memory transfert have occured. (to avoid too fast downtime increment)

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuMigrate.pm |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 38f1d05..4239e51 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -349,7 +349,7 @@ sub phase2 {
     if (defined($migrate_downtime)) {
 	$self->log('info', "migrate_set_downtime: $migrate_downtime");
 	eval {
-	    PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate_set_downtime", value => int($migrate_downtime));
+	    PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate_set_downtime", value => int($migrate_downtime*100)/100);
 	};
 	$self->log('info', "migrate_set_downtime error: $@") if $@;
     }
@@ -377,6 +377,8 @@ sub phase2 {
     my $usleep = 2000000;
     my $i = 0;
     my $err_count = 0;
+    my $lastrem = undef;
+    my $downtimecounter = 0;
     while (1) {
 	$i++;
 	my $avglstat = $lstat/$i if $lstat;
@@ -433,8 +435,24 @@ sub phase2 {
 			   "remaining ${rem}), total ${total}) , expected downtime ${expected_downtime}");
 
 		#$self->log('info', "migration xbzrle cachesize: ${xbzrlecachesize} transferred ${xbzrlebytes} pages ${xbzrlepages} cachemiss ${xbzrlecachemiss} overflow ${xbzrleoverflow}");
+		if (($lastrem  && $rem > $lastrem ) || ($rem == 0)) {
+		    $downtimecounter++;
+		}
+		$lastrem = $rem;
+
+		if ($downtimecounter > 5) {
+		    $downtimecounter = 0;
+		    $migrate_downtime *= 2;
+		    $self->log('info', "migrate_set_downtime: $migrate_downtime");
+		    eval {
+			PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate_set_downtime", value => int($migrate_downtime*100)/100);
+		    };
+		    $self->log('info', "migrate_set_downtime error: $@") if $@;
+            	}
+
 	    }
 
+
 	    $lstat = $stat->{ram}->{transferred};
 	    
 	} else {
-- 
1.7.10.4




More information about the pve-devel mailing list