[pve-devel] [PATCH] increase migrate_set_downtime only if expected downtime is more than 30 iterations > 0

Stefan Priebe s.priebe at profihost.ag
Sun Dec 30 13:25:40 CET 2012


Hi,

attached a patch.

Greets,
Stefan

Am 30.12.2012 09:39, schrieb Alexandre DERUMIER:
>>> What about every 15seconds if no progress has happened? How would
>>> you define progress?
>
> Maybe we can check if remaining memory goes up and down.
> (So it could also works with qemu 1.4 as we dont have expected_downtime value)
>
> (if remaining memory > last remaing memory){
>   counter++
> }
>
> if(counter == 15){
>
>   set_migrate_downtime = migratedowntime + 0.X sec
>   counter = 0;
> }
>
>
>
>
>
>
>
>
>
>
> ----- Mail original -----
>
> De: "Stefan Priebe - Profihost AG" <s.priebe at profihost.ag>
> À: "Dietmar Maurer" <dietmar at proxmox.com>
> Cc: "Alexandre Derumier" <aderumier at odiso.com>, pve-devel at pve.proxmox.com
> Envoyé: Dimanche 30 Décembre 2012 09:33:09
> Objet: Re: [pve-devel] [PATCH] increase migrate_set_downtime only if expected downtime is more than 30 iterations > 0
>
> What about every 15seconds if no progress has happened? How would
> you define progress?
>
> I would then start at 0.15s downtime as
> default or at custom conf value if defined. If no progress happens I would double the value.
>
> Stefan
>
> Am 30.12.2012 um 06:55 schrieb Dietmar Maurer <dietmar at proxmox.com>:
>
>>> i really like that idea instead of having a fixed downtime of 1s. What is about
>>> starting at 0.5s and then add 0.5s every 15 runs?
>>
>> Yes, we can do that, but may "Every 15 runs if we make no progress"?
>>
-------------- next part --------------
From a1dd1fb3aad3317a5d571688e1bf6726338232d4 Mon Sep 17 00:00:00 2001
From: Stefan Priebe <s.priebe at profihost.ag>
Date: Sat, 29 Dec 2012 20:23:23 +0100
Subject: [PATCH] implement dynamic migration_downtime

---
 PVE/QemuMigrate.pm |   21 +++++++++++++++++++--
 PVE/QemuServer.pm  |    4 ++--
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index ab01fa0..f290975 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -348,9 +348,9 @@ sub phase2 {
     my $migrate_downtime = $defaults->{migrate_downtime};
     $migrate_downtime = $conf->{migrate_downtime} if defined($conf->{migrate_downtime});
     if (defined($migrate_downtime)) {
-	$self->log('info', "migrate_set_downtime: $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 $@;
     }
@@ -379,6 +379,8 @@ sub phase2 {
     my $usleep = 2000000;
     my $i = 0;
     my $err_count = 0;
+    my $migration_lastremaining = 0;
+    my $migrate_downtimecounter = 0;
     while (1) {
 	$i++;
 	my $avglstat = $lstat/$i if $lstat;
@@ -437,6 +439,21 @@ sub phase2 {
 		#$self->log('info', "migration xbzrle cachesize: ${xbzrlecachesize} transferred ${xbzrlebytes} pages ${xbzrlepages} cachemiss ${xbzrlecachemiss} overflow ${xbzrleoverflow}");
 	    }
 
+            if ($stat->{ram}->{remaining} && $stat->{ram}->{remaining} > $migration_lastremaining) {
+		$migration_lastremaining = $stat->{ram}->{remaining};
+		$migrate_downtimecounter++;
+	    }
+            if ($migrate_downtimecounter > 5) {
+		$migrate_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 $@;
+		$migrate_downtimecounter = time();
+            }
+
 	    $lstat = $stat->{ram}->{transferred};
 	    
 	} else {
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 93d0300..524a15c 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -382,10 +382,10 @@ EODESCR
     },
     migrate_downtime => {
 	optional => 1,
-	type => 'integer',
+	type => 'number',
 	description => "Set maximum tolerated downtime (in seconds) for migrations.",
 	minimum => 0,
-	default => 1,
+	default => 0.1,
     },
     cdrom => {
 	optional => 1,
-- 
1.7.10.4



More information about the pve-devel mailing list