mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-02 18:59:41 +00:00
drive-mirror : die if stats are empty.
If drive have bad sectors, the block job die. we need to die if stats are empty to avoid this: transferred: 21440086016 bytes remaining: 34668544 bytes total: 21474754560 bytes progression: 99.84 % Use of uninitialized value $transferred in subtraction (-) at /usr/share/perl5/PVE/QemuServer.pm line 4611. Use of uninitialized value $total in subtraction (-) at /usr/share/perl5/PVE/QemuServer.pm line 4611. Use of uninitialized value $transferred in multiplication (*) at /usr/share/perl5/PVE/QemuServer.pm line 4612. Use of uninitialized value $total in division (/) at /usr/share/perl5/PVE/QemuServer.pm line 4612. clone failed: mirroring error: Illegal division by zero at /usr/share/perl5/PVE/QemuServer.pm line 4612. Maybe it should be improved by catching qmp events, but doesn't seem to work for now Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
4fca015325
commit
f6ab3bdbf9
@ -4606,11 +4606,13 @@ sub qemu_drive_mirror {
|
||||
while (1) {
|
||||
my $stats = PVE::QemuServer::vm_mon_cmd($vmid, "query-block-jobs");
|
||||
my $stat = @$stats[0];
|
||||
die "mirroring job seem to have die. Maybe do you have bad sectors?" if !$stat;
|
||||
die "error job is not mirroring" if $stat->{type} ne "mirror";
|
||||
|
||||
my $transferred = $stat->{offset};
|
||||
my $total = $stat->{len};
|
||||
my $remaining = $total - $transferred;
|
||||
my $percent = sprintf "%.2f", ($transferred * 100 / $total);
|
||||
die "error job is not mirroring" if $stat->{type} ne "mirror";
|
||||
|
||||
print "transferred: $transferred bytes remaining: $remaining bytes total: $total bytes progression: $percent %\n";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user