]> git.proxmox.com Git - qemu-server.git/commitdiff
drive-mirror : die if stats are empty.
authorAlexandre Derumier <aderumier@odiso.com>
Mon, 6 May 2013 09:21:01 +0000 (11:21 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 6 May 2013 09:29:41 +0000 (11:29 +0200)
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>
PVE/QemuServer.pm

index a15bf265255943d9ea2fc4ab874431fef7a008e2..c31d08a9d3cce03afc251b6553d55c9293ea825c 100644 (file)
@@ -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";