[pve-devel] [PATCH qemu-server] block job: mirror: always detach the target node upon cancelling
Fiona Ebner
f.ebner at proxmox.com
Thu Jul 31 11:09:49 CEST 2025
This is a further improvement after commit 8e671e79 ("block job:
mirror: always detach the target node upon error"). It might be
that a cancelled job ends up in concluded state without an error
being set in the result of the 'query-block-jobs' QMP command and
the target node would not be detached. To fix it, also detach the
target node when cancelling the job. This is correct even when the job
was cancelled after completion, as in that case, the drive is not
switched over to use the target node.
Reported-by: Friedrich Weber <f.weber at proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/PVE/QemuServer/BlockJob.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/PVE/QemuServer/BlockJob.pm b/src/PVE/QemuServer/BlockJob.pm
index f742b184..633c0b34 100644
--- a/src/PVE/QemuServer/BlockJob.pm
+++ b/src/PVE/QemuServer/BlockJob.pm
@@ -28,8 +28,10 @@ sub qemu_handle_concluded_blockjob {
eval { mon_cmd($vmid, 'job-dismiss', id => $job_id); };
log_warn("$job_id: failed to dismiss job - $@") if $@;
- # If there was an error, always detach the target.
- $job->{'detach-node-name'} = $job->{'target-node-name'} if $qmp_info->{error};
+ # If there was an error or if the job was cancelled, always detach the target. This is correct
+ # even when the job was cancelled after completion, because then the disk is not switched over
+ # to use the target.
+ $job->{'detach-node-name'} = $job->{'target-node-name'} if $qmp_info->{error} || $job->{cancel};
if (my $node_name = $job->{'detach-node-name'}) {
eval { PVE::QemuServer::Blockdev::detach($vmid, $node_name); };
--
2.47.2
More information about the pve-devel
mailing list