[pve-devel] [RFC qemu-server 2/2] qemu_drive_mirror_monitor: refactor job status out in own variable
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Jun 28 14:14:18 CEST 2018
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
PVE/QemuServer.pm | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index b4fa30a..bd3307a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6280,28 +6280,28 @@ sub qemu_drive_mirror_monitor {
my $readycounter = 0;
foreach my $job (keys %$jobs) {
+ my $status = $running_mirror_jobs->{$job};
- if(defined($jobs->{$job}->{complete}) && !defined($running_mirror_jobs->{$job})) {
+ if (defined($jobs->{$job}->{complete}) && !defined($status)) {
print "$job : finished\n";
delete $jobs->{$job};
next;
}
- die "$job: mirroring has been cancelled\n" if !defined($running_mirror_jobs->{$job});
+ die "$job: mirroring has been cancelled\n" if !defined($status);
- my $ready = $running_mirror_jobs->{$job}->{ready};
- if (my $total = $running_mirror_jobs->{$job}->{len}) {
- my $transferred = $running_mirror_jobs->{$job}->{offset} || 0;
+ if (my $total = $status->{len}) {
+ my $transferred = $status->{offset} || 0;
my $percent = sprintf "%.2f", ($transferred * 100 / $total);
my $stats = bytes2human($transferred) . ' from ' . bytes2human($total);
print "$job: transferred: $stats ($percent %)";
- print " - job ready" if $ready;
+ print " - job ready" if $status->{ready};
print "\n";
}
- $readycounter++ if $running_mirror_jobs->{$job}->{ready};
+ $readycounter++ if $status->{ready};
}
last if scalar(keys %$jobs) == 0;
--
2.17.1
More information about the pve-devel
mailing list