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 <aderum...@odiso.com>
---
 PVE/QemuServer.pm |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index a15bf26..c31d08a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -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";
 
-- 
1.7.10.4

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to