* [pve-devel] [PATCH qemu-server] block job: mirror: always detach the target node upon cancelling
@ 2025-07-31 9:09 Fiona Ebner
2025-07-31 9:16 ` Friedrich Weber
2025-07-31 9:39 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 2 replies; 3+ messages in thread
From: Fiona Ebner @ 2025-07-31 9:09 UTC (permalink / raw)
To: pve-devel
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@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@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
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH qemu-server] block job: mirror: always detach the target node upon cancelling
2025-07-31 9:09 [pve-devel] [PATCH qemu-server] block job: mirror: always detach the target node upon cancelling Fiona Ebner
@ 2025-07-31 9:16 ` Friedrich Weber
2025-07-31 9:39 ` [pve-devel] applied: " Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Friedrich Weber @ 2025-07-31 9:16 UTC (permalink / raw)
To: Proxmox VE development discussion, Fiona Ebner
On 31/07/2025 11:09, Fiona Ebner wrote:
> 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@proxmox.com>
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
Thanks for the patch!
Seems to fix my reproducer:
Without this patch (`opt` being a directory storage):
# qm stop 101; qm destroy 101; qm create 101 --scsi0 local-lvm:1; qm start 101; timeout 1 qm disk move 101 scsi0 opt; qm disk move 101 scsi0 opt
Logical volume "vm-101-disk-0" successfully removed.
Logical volume "vm-101-disk-0" created.
Logical volume pve/vm-101-disk-0 changed.
scsi0: successfully created disk 'local-lvm:vm-101-disk-0,size=1G'
create full clone of drive scsi0 (local-lvm:vm-101-disk-0)
Formatting '/opt/images/101/vm-101-disk-0.raw', fmt=raw size=1073741824 preallocation=off
drive mirror is starting for drive-scsi0
mirror-scsi0: transferred 85.0 MiB of 1.0 GiB (8.30%) in 0s
mirror-scsi0: Cancelling block job
mirror-scsi0: Done.
storage migration failed: block job (mirror) error: interrupted by signal
create full clone of drive scsi0 (local-lvm:vm-101-disk-0)
Formatting '/opt/images/101/vm-101-disk-0.raw', fmt=raw size=1073741824 preallocation=off
storage migration failed: adding blockdev 'zc34a13b971104aab98614370f1a40f' failed : VM 101 qmp command 'blockdev-add' failed - Duplicate nodes with node-name='zc34a13b971104aab98614370f1a40f'
With this patch:
# qm stop 101; qm destroy 101; qm create 101 --scsi0 local-lvm:1; qm start 101; timeout 1 qm disk move 101 scsi0 opt; qm disk move 101 scsi0 opt
Logical volume "vm-101-disk-0" successfully removed.
Logical volume "vm-101-disk-0" created.
Logical volume pve/vm-101-disk-0 changed.
scsi0: successfully created disk 'local-lvm:vm-101-disk-0,size=1G'
create full clone of drive scsi0 (local-lvm:vm-101-disk-0)
Formatting '/opt/images/101/vm-101-disk-0.raw', fmt=raw size=1073741824 preallocation=off
drive mirror is starting for drive-scsi0
mirror-scsi0: transferred 142.0 MiB of 1.0 GiB (13.87%) in 0s
mirror-scsi0: Cancelling block job
mirror-scsi0: Done.
storage migration failed: block job (mirror) error: interrupted by signal
create full clone of drive scsi0 (local-lvm:vm-101-disk-0)
Formatting '/opt/images/101/vm-101-disk-0.raw', fmt=raw size=1073741824 preallocation=off
drive mirror is starting for drive-scsi0
mirror-scsi0: transferred 13.0 MiB of 1.0 GiB (1.27%) in 0s
mirror-scsi0: transferred 1.0 GiB of 1.0 GiB (100.00%) in 1s, ready
all 'mirror' jobs are ready
mirror-scsi0: Completing block job...
mirror-scsi0: Completed successfully.
mirror-scsi0: mirror-job finished
So consider this
Tested-by: Friedrich Weber <f.weber@proxmox.com>
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] applied: [PATCH qemu-server] block job: mirror: always detach the target node upon cancelling
2025-07-31 9:09 [pve-devel] [PATCH qemu-server] block job: mirror: always detach the target node upon cancelling Fiona Ebner
2025-07-31 9:16 ` Friedrich Weber
@ 2025-07-31 9:39 ` Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2025-07-31 9:39 UTC (permalink / raw)
To: pve-devel, Fiona Ebner
On Thu, 31 Jul 2025 11:09:49 +0200, Fiona Ebner wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] block job: mirror: always detach the target node upon cancelling
commit: 0b9090c6abf4a51558e9a6fba88388abe666a512
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-31 9:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-31 9:09 [pve-devel] [PATCH qemu-server] block job: mirror: always detach the target node upon cancelling Fiona Ebner
2025-07-31 9:16 ` Friedrich Weber
2025-07-31 9:39 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox