[pve-devel] [PATCH] migration : enable auto-converge capability v2

Alexandre Derumier aderumier at odiso.com
Thu Jan 9 10:58:48 CET 2014


This reduce guest cpu speed if dirtied bytes is 50% more than the approx.amount of bytes that just got transferred since the last time we were in this routine.

qemu commit :
http://git.qemu.org/?p=qemu.git;a=commit;h=bde1e2ec2176c363c1783bf8887b6b1beb08dfee

tested with "stress -m 2 -c 2" under debian

without autoconvergence : downtime 12s - duration 12min
with autoconvergence : downtime 2s - duration 4min

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuMigrate.pm |    7 ++-----
 PVE/QemuServer.pm  |   36 +++++++++++++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index d980f0b..f5c86c8 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -385,13 +385,10 @@ sub phase2 {
 	$self->log('info', "migrate_set_downtime error: $@") if $@;
     }
 
-    my $capabilities = {};
-    $capabilities->{capability} =  "xbzrle";
-    $capabilities->{state} = JSON::false;
-
     eval {
-	PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-capabilities", capabilities => [$capabilities]);
+	PVE::QemuServer::set_migration_caps($vmid);
     };
+    warn $@ if $@;
 
     #set cachesize 10% of the total memory
     my $cachesize = int($conf->{memory}*1048576/10);
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index a5576a6..591a863 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3094,6 +3094,32 @@ sub qga_unfreezefs {
     #need to impplement call to qemu-ga
 }
 
+sub PVE::QemuServer::set_migration_caps { 
+    my ($vmid) = @_; 
+
+    my @capabilities = ();
+    my $cap_ref = \@capabilities;
+
+    my $enabled_cap = {
+       "auto-converge" => 1,
+       "xbzrle" => 0,
+       "x-rdma-pin-all" => 0,
+       "zero-blocks" => 0,
+    };
+
+    my $supported_capabilities = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "query-migrate-capabilities");
+
+    for my $supported_capability (@$supported_capabilities){
+	if($enabled_cap->{$supported_capability->{capability}} eq 1){
+	    my $capability->{capability} = $supported_capability->{capability};
+	    $capability->{state} = JSON::true;
+	    push(@$cap_ref,$capability);
+        }
+    }
+
+    PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "migrate-set-capabilities", capabilities => $cap_ref);
+} 
+
 sub vm_start {
     my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused, $forcemachine, $spice_ticket) = @_;
 
@@ -3160,12 +3186,12 @@ sub vm_start {
 	}
 
 	if ($migratedfrom) {
-	    my $capabilities = {};
-	    $capabilities->{capability} =  "xbzrle";
-	    $capabilities->{state} = JSON::true;
-	    eval { vm_mon_cmd_nocheck($vmid, "migrate-set-capabilities", capabilities => [$capabilities]); };
+
+	    eval {
+		PVE::QemuServer::set_migration_caps($vmid);
+	    };
 	    warn $@ if $@;
-	    
+
 	    if ($spice_port) {
 	        print "spice listens on port $spice_port\n";
 		if ($spice_ticket) {
-- 
1.7.10.4




More information about the pve-devel mailing list