From b68a957b2ef14a0ff8419dd79738f6d46bbeca7b Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 19 Apr 2021 22:01:05 +0200 Subject: [PATCH] migration: keep log rate steady if polling gets more frequent Either we're done in a few seconds anyway, or if the VM dirties lots of pages we need quite a bit of time, and then it does not help to output roughly the same status 10 times a second... Signed-off-by: Thomas Lamprecht --- PVE/QemuMigrate.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 6be0bf90..64551824 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -1101,6 +1101,8 @@ sub phase2 { # reduce sleep if remainig memory is lower than the average transfer speed $usleep = 100_000 if $avglstat && $rem < $avglstat; + # also reduce loggin if we poll more frequent + my $should_log = $usleep > 100_000 ? 1 : ($i % 10) == 0; my $total_h = render_bytes($total, 1); my $transferred_h = render_bytes($trans, 1); @@ -1113,7 +1115,7 @@ sub phase2 { $progress .= ", VM dirties lots of memory: $dirty_rate_h/s"; } - $self->log('info', "migration $status, $progress"); + $self->log('info', "migration $status, $progress") if $should_log; my $xbzrle = $stat->{"xbzrle-cache"} || {}; my ($xbzrlebytes, $xbzrlepages) = $xbzrle->@{'bytes', 'pages'}; @@ -1127,7 +1129,7 @@ sub phase2 { $msg .= ", overflow $xbzrle->{overflow}" if $xbzrle->{overflow}; - $self->log('info', "xbzrle: $msg"); + $self->log('info', "xbzrle: $msg") if $should_log; } if (($lastrem && $rem > $lastrem) || ($rem == 0)) {