From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 568581FF16B for ; Tue, 1 Jul 2025 17:44:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 59787A609; Tue, 1 Jul 2025 17:42:10 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 1 Jul 2025 17:40:53 +0200 Message-ID: <20250701154117.434512-34-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250701154117.434512-1-f.ebner@proxmox.com> References: <20250701154117.434512-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.029 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 Subject: [pve-devel] [PATCH qemu-server v2 33/49] block job: allow specifying a block node that should be detached upon completion 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: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" In preparation for blockdev-mirror, where the node that is not used anymore (either source when switching to target, or otherwise target) needs to be detached. Signed-off-by: Fiona Ebner --- src/PVE/QemuServer/BlockJob.pm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/PVE/QemuServer/BlockJob.pm b/src/PVE/QemuServer/BlockJob.pm index d26bcb01..68d0431f 100644 --- a/src/PVE/QemuServer/BlockJob.pm +++ b/src/PVE/QemuServer/BlockJob.pm @@ -18,13 +18,20 @@ use PVE::QemuServer::RunState; # 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. +# $job is the information about the job recorded on the PVE-side. +# A block node $job->{'detach-node-name'} will be detached if present. sub qemu_handle_concluded_blockjob { - my ($vmid, $job_id, $info) = @_; + my ($vmid, $job_id, $qmp_info, $job) = @_; 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}; + if (my $node_name = $job->{'detach-node-name'}) { + eval { PVE::QemuServer::Blockdev::detach($vmid, $node_name); }; + log_warn($@) if $@; + } + + die "$job_id: $qmp_info->{error} (io-status: $qmp_info->{'io-status'})\n" if $qmp_info->{error}; } sub qemu_blockjobs_cancel { @@ -47,7 +54,7 @@ sub qemu_blockjobs_cancel { foreach my $job (keys %$jobs) { my $info = $running_jobs->{$job}; eval { - qemu_handle_concluded_blockjob($vmid, $job, $info) + qemu_handle_concluded_blockjob($vmid, $job, $info, $jobs->{$job}) if $info && $info->{status} eq 'concluded'; }; log_warn($@) if $@; # only warn and proceed with canceling other jobs @@ -106,7 +113,7 @@ sub qemu_drive_mirror_monitor { die "$job_id: '$op' has been cancelled\n" if !defined($job); - qemu_handle_concluded_blockjob($vmid, $job_id, $job) + qemu_handle_concluded_blockjob($vmid, $job_id, $job, $jobs->{$job_id}) if $job && $job->{status} eq 'concluded'; my $busy = $job->{busy}; @@ -322,7 +329,7 @@ sub qemu_drive_mirror_switch_to_active_mode { my $info = $running_jobs->{$job}; if ($info->{status} eq 'concluded') { - qemu_handle_concluded_blockjob($vmid, $job, $info); + qemu_handle_concluded_blockjob($vmid, $job, $info, $jobs->{$job}); # The 'concluded' state should occur here if and only if the job failed, so the # 'die' below should be unreachable, but play it safe. die "$job: expected job to have failed, but no error was set\n"; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel