From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A19EA94E38 for ; Thu, 11 Apr 2024 13:16:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 894D430429 for ; Thu, 11 Apr 2024 13:16:11 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 11 Apr 2024 13:16:10 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 09C1444B44 for ; Thu, 11 Apr 2024 13:16:10 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Thu, 11 Apr 2024 13:16:03 +0200 Message-Id: <20240411111606.73267-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240411111606.73267-1-f.ebner@proxmox.com> References: <20240411111606.73267-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.071 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [qemuserver.pm] Subject: [pve-devel] [PATCH v2 qemu-server 1/4] blockjob: anticipate jobs with auto-dismiss=false for better error messages and detection X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Apr 2024 11:16:11 -0000 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 --- 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