[pve-devel] [PATCH qemu-server] block job: mirror: always detach the target node upon error

Hannes Duerr h.duerr at proxmox.com
Mon Jul 28 14:08:40 CEST 2025


I attempted to migrate a VM with its disk on local storage, but this 
failed due to insufficient space on the target node.
I then moved the disk to shared storage and attempted the migration again.
This time, the migration succeeded.

Please consider this:

Tested-by: Hannes Duerr <h.duerr at proxmox.com>

On 7/28/25 12:07 PM, Fiona Ebner wrote:
> For example, attempting to live-migrate a disk again after failure
> would not work, because a node with the same name would still be
> attached.
>
> Mirroring the disk to a shared storage after VM live-migration failure
> and then attempting VM live-migration again, would result in
>
>> migration status error: failed - Error in migration completion: Input/output error
> This is because for migration completion, all attached block devices
> are flushed, but the NBD export does not exist on the target side
> anymore.
>
> Fixes: 1da91175 ("block job: add blockdev mirror")
> Reported-by: Hannes Dürr <h.duerr at proxmox.com>
> Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
>   src/PVE/QemuServer/BlockJob.pm | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/src/PVE/QemuServer/BlockJob.pm b/src/PVE/QemuServer/BlockJob.pm
> index 9c04600b..f742b184 100644
> --- a/src/PVE/QemuServer/BlockJob.pm
> +++ b/src/PVE/QemuServer/BlockJob.pm
> @@ -28,6 +28,9 @@ 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 (my $node_name = $job->{'detach-node-name'}) {
>           eval { PVE::QemuServer::Blockdev::detach($vmid, $node_name); };
>           log_warn($@) if $@;




More information about the pve-devel mailing list