From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 qemu-server 1/4] blockjob: anticipate jobs with auto-dismiss=false for better error messages and detection
Date: Thu, 11 Apr 2024 13:16:03 +0200 [thread overview]
Message-ID: <20240411111606.73267-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20240411111606.73267-1-f.ebner@proxmox.com>
When auto-dismiss=true (the default), a failed job can disappear very
quickly from the job list and there might not be any chance to see the
error in the result of 'query-block-jobs'. For jobs with $completion
being 'auto', like 'block-stream', it couldn't even be detected that
the job failed.
Jobs with auto-dismiss=false on the other hand, will wait in
'concluded' state until manually dismissed. For those, it will be
possible to query the error if the job failed.
There doesn't seem to be a way to have only failed jobs stay around,
e.g. something like auto-dismiss=on-success.
Planned to be used for the 'drive-mirror' and 'block-stream' jobs
initially.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
PVE/QemuServer.pm | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index abe175a4..e5543237 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -7976,6 +7976,9 @@ sub qemu_drive_mirror_monitor {
die "$job_id: '$op' has been cancelled\n" if !defined($job);
+ qemu_handle_concluded_blockjob($vmid, $job_id, $job)
+ if $job && $job->{status} eq 'concluded';
+
my $busy = $job->{busy};
my $ready = $job->{ready};
if (my $total = $job->{len}) {
@@ -8076,6 +8079,19 @@ sub qemu_drive_mirror_monitor {
}
}
+# If the job was started with auto-dismiss=false, it's necessary to dismiss it manually. Using this
+# option is useful to get the error for failed jobs here. QEMU's job lock should make it impossible
+# to see a job in 'concluded' state when auto-dismiss=true.
+# $info is the 'BlockJobInfo' for the job returned by query-block-jobs.
+sub qemu_handle_concluded_blockjob {
+ my ($vmid, $job_id, $info) = @_;
+
+ eval { mon_cmd($vmid, 'job-dismiss', id => $job_id); };
+ log_warn("$job_id: failed to dismiss job - $@") if $@;
+
+ die "$job_id: $info->{error} (io-status: $info->{'io-status'})\n" if $info->{error};
+}
+
sub qemu_blockjobs_cancel {
my ($vmid, $jobs) = @_;
@@ -8094,8 +8110,14 @@ sub qemu_blockjobs_cancel {
}
foreach my $job (keys %$jobs) {
+ my $info = $running_jobs->{$job};
+ eval {
+ qemu_handle_concluded_blockjob($vmid, $job, $info)
+ if $info && $info->{status} eq 'concluded';
+ };
+ log_warn($@) if $@; # only warn and proceed with canceling other jobs
- if (defined($jobs->{$job}->{cancel}) && !defined($running_jobs->{$job})) {
+ if (defined($jobs->{$job}->{cancel}) && !defined($info)) {
print "$job: Done.\n";
delete $jobs->{$job};
}
--
2.39.2
next prev parent reply other threads:[~2024-04-11 11:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 11:16 [pve-devel] [PATCH-SERIES v2 qemu-server] improve error detection/messages for some block jobs Fiona Ebner
2024-04-11 11:16 ` Fiona Ebner [this message]
2024-04-11 11:16 ` [pve-devel] [PATCH v2 qemu-server 2/4] mirror: do not auto-dismiss to allow getting error message from job Fiona Ebner
2024-04-11 11:16 ` [pve-devel] [PATCH v2 qemu-server 3/4] live restore: do not auto-dismiss stream job to improve error message and detection Fiona Ebner
2024-04-11 11:16 ` [pve-devel] [PATCH v2 qemu-server 4/4] live import: " Fiona Ebner
2024-07-02 14:08 ` [pve-devel] applied-series: [PATCH-SERIES v2 qemu-server] improve error detection/messages for some block jobs Fabian Grünbichler
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=20240411111606.73267-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal