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 EA00AB901C for ; Tue, 12 Mar 2024 12:59:56 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CCE5D16E6C for ; Tue, 12 Mar 2024 12:59:26 +0100 (CET) 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 ; Tue, 12 Mar 2024 12:59:25 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 830DD43E54 for ; Tue, 12 Mar 2024 12:59:25 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 12 Mar 2024 12:59:20 +0100 Message-Id: <20240312115922.101416-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312115922.101416-1-f.ebner@proxmox.com> References: <20240312115922.101416-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.070 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH qemu-server 1/3] 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: Tue, 12 Mar 2024 11:59:57 -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 ed8b054e..07e005eb 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -7883,6 +7883,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}) { @@ -7983,6 +7986,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) = @_; @@ -8001,8 +8017,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