mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-07-03 09:13:11 +00:00
migrate: fix warning about uninitialized values
And display acurate byte values instead of KB
This commit is contained in:
parent
f0002f62f1
commit
a05b47a8a8
@ -329,28 +329,13 @@ sub phase2 {
|
||||
};
|
||||
my $merr = $@;
|
||||
|
||||
my $lstat = undef;
|
||||
my $lstat = 0;
|
||||
while (1) {
|
||||
sleep (2);
|
||||
my $stat = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, "query-migrate");
|
||||
|
||||
if ($stat->{status} =~ m/^(active|completed|failed|cancelled)$/im) {
|
||||
$merr = undef;
|
||||
|
||||
if ($stat->{ram}->{transferred} ne $lstat) {
|
||||
if ($stat->{status} eq 'active') {
|
||||
my ($trans, $rem, $total) = (0, 0, 0);
|
||||
$trans = sprintf "%.2f", $stat->{ram}->{transferred}/1024 if $stat->{ram}->{transferred};
|
||||
$rem = sprintf "%.2f", $stat->{ram}->{remaining}/1024 if $stat->{ram}->{remaining};
|
||||
$total = sprintf "%.2f", $stat->{ram}->{total}/1024 if $stat->{ram}->{total};
|
||||
|
||||
$self->log('info', "migration status: $stat->{status} (transferred ${trans}KB, " .
|
||||
"remaining ${rem}KB), total ${total}KB)");
|
||||
} else {
|
||||
$self->log('info', "migration status: $stat->{status}");
|
||||
}
|
||||
}
|
||||
|
||||
if ($stat->{status} eq 'completed') {
|
||||
my $delay = time() - $start;
|
||||
if ($delay > 0) {
|
||||
@ -363,13 +348,27 @@ sub phase2 {
|
||||
die "aborting\n"
|
||||
}
|
||||
|
||||
last if $stat->{status} ne 'active';
|
||||
if ($stat->{status} ne 'active') {
|
||||
$self->log('info', "migration status: $stat->{status}");
|
||||
last;
|
||||
}
|
||||
|
||||
if ($stat->{ram}->{transferred} ne $lstat) {
|
||||
my $trans = $stat->{ram}->{transferred} || 0;
|
||||
my $rem = $stat->{ram}->{remaining} || 0;
|
||||
my $total = $stat->{ram}->{total} || 0;
|
||||
|
||||
$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";
|
||||
}
|
||||
$lstat = $lstat->{ram}->{transferred};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
sub phase3 {
|
||||
|
Loading…
Reference in New Issue
Block a user