From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server 4/8] block job: monitor: factor out job status printing
Date: Thu, 30 Jul 2026 15:15:53 +0200 [thread overview]
Message-ID: <20260730131613.157722-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20260730131613.157722-1-f.ebner@proxmox.com>
The validity/presence of $job->{ready} does not depend on $job->{len}
in any way, so does not need to be part of the if block.
No functional change intended.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/BlockJob.pm | 57 +++++++++++++++++++---------------
1 file changed, 32 insertions(+), 25 deletions(-)
diff --git a/src/PVE/QemuServer/BlockJob.pm b/src/PVE/QemuServer/BlockJob.pm
index 3c8de3e4..14d814ee 100644
--- a/src/PVE/QemuServer/BlockJob.pm
+++ b/src/PVE/QemuServer/BlockJob.pm
@@ -79,6 +79,35 @@ sub qemu_blockjobs_cancel {
}
}
+my sub print_job_status {
+ my ($job_id, $job, $duration) = @_;
+
+ if (my $total = $job->{len}) {
+ my $transferred = $job->{offset} || 0;
+ my $remaining = $total - $transferred;
+ my $percent = sprintf "%.2f", ($transferred * 100 / $total);
+
+ my $total_h = render_bytes($total, 1);
+ my $transferred_h = render_bytes($transferred, 1);
+
+ my $status = sprintf(
+ "transferred $transferred_h of $total_h ($percent%%) in %s",
+ render_duration($duration),
+ );
+
+ if ($job->{ready}) {
+ if ($job->{busy}) {
+ $status .= ", still busy"; # shouldn't even happen? but mirror is weird
+ } else {
+ $status .= ", ready";
+ }
+ }
+ print "$job_id: $status\n";
+ }
+
+ return;
+}
+
# $completion can be either
# 'complete': wait until all jobs are ready, job-complete them (default)
# 'cancel': wait until all jobs are ready, block-job-cancel them
@@ -130,32 +159,10 @@ sub monitor {
qemu_handle_concluded_blockjob($qmp_peer, $job_id, $job, $jobs->{$job_id});
}
- my $busy = $job->{busy};
- my $ready = $job->{ready};
- if (my $total = $job->{len}) {
- my $transferred = $job->{offset} || 0;
- my $remaining = $total - $transferred;
- my $percent = sprintf "%.2f", ($transferred * 100 / $total);
-
- my $duration = $ctime - $starttime;
- my $total_h = render_bytes($total, 1);
- my $transferred_h = render_bytes($transferred, 1);
-
- my $status = sprintf(
- "transferred $transferred_h of $total_h ($percent%%) in %s",
- render_duration($duration),
- );
-
- if ($ready) {
- if ($busy) {
- $status .= ", still busy"; # shouldn't even happen? but mirror is weird
- } else {
- $status .= ", ready";
- }
- }
- print "$job_id: $status\n" if !$jobs->{$job_id}->{ready};
- $jobs->{$job_id}->{ready} = $ready;
+ if (!$jobs->{$job_id}->{ready}) {
+ print_job_status($job_id, $job, $ctime - $starttime);
}
+ $jobs->{$job_id}->{ready} = $job->{ready};
$readycounter++ if $job->{ready};
}
--
2.47.3
next prev parent reply other threads:[~2026-07-30 13:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 13:15 [PATCH-SERIES qemu-server 0/8] block job: monitor: improve completion handling and style Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 1/8] block job: monitor: avoid duplicate completion Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 2/8] block job: monitor: only print message that jobs are ready once Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 3/8] partially fix #7854: block job: monitor: handle completion faster to benefit migration Fiona Ebner
2026-07-30 13:15 ` Fiona Ebner [this message]
2026-07-30 13:15 ` [PATCH qemu-server 5/8] block job: monitor: make operation argument non-optional Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 6/8] block job: monitor: rename 'op' argument to 'operation' Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 7/8] block job: monitor: pass options as a hash Fiona Ebner
2026-07-30 13:15 ` [PATCH qemu-server 8/8] block job: monitor: properly document function Fiona Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260730131613.157722-5-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox