When the format is raw, the size can be explicitly passed. When the format is a container format like qcow2, the image should already be allocated with the correct virtual size.
It is not possible to resize a disk with an explicit 'size' set, so only set this for EFI disks. Signed-off-by: Fiona Ebner <f.eb...@proxmox.com> --- src/PVE/QemuServer/BlockJob.pm | 18 ++++++++++++++++++ src/PVE/QemuServer/Blockdev.pm | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/PVE/QemuServer/BlockJob.pm b/src/PVE/QemuServer/BlockJob.pm index fc12f310..9c04600b 100644 --- a/src/PVE/QemuServer/BlockJob.pm +++ b/src/PVE/QemuServer/BlockJob.pm @@ -455,6 +455,24 @@ sub blockdev_mirror { my $attach_dest_opts = { 'no-throttle' => 1 }; $attach_dest_opts->{'zero-initialized'} = 1 if $dest->{'zero-initialized'}; + # Source and target need to have the exact same virtual size, see bug #3227. + # However, it won't be possible to resize a disk with 'size' explicitly set afterwards, so only + # set it for EFI disks. + if ($drive_id eq 'efidisk0' && !PVE::QemuServer::Blockdev::is_nbd($dest_drive)) { + my ($storeid) = PVE::Storage::parse_volume_id($dest_drive->{file}, 1); + if ( + $storeid + && PVE::QemuServer::Drive::checked_volume_format($storecfg, $dest->{volid}) eq 'raw' + ) { + my $block_info = PVE::QemuServer::Blockdev::get_block_info($vmid); + if (my $size = $block_info->{$drive_id}->{inserted}->{image}->{'virtual-size'}) { + $attach_dest_opts->{size} = $size; + } else { + log_warn("unable to determine source block node size - continuing anyway"); + } + } + } + # Note that if 'aio' is not explicitly set, i.e. default, it can change if source and target # don't both allow or both not allow 'io_uring' as the default. my $target_node_name = diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm index ab58e3ea..334f788b 100644 --- a/src/PVE/QemuServer/Blockdev.pm +++ b/src/PVE/QemuServer/Blockdev.pm @@ -19,7 +19,7 @@ use PVE::QemuServer::Monitor qw(mon_cmd); my $NBD_TCP_PATH_RE_3 = qr/nbd:(\S+):(\d+):exportname=(\S+)/; my $NBD_UNIX_PATH_RE_2 = qr/nbd:unix:(\S+):exportname=(\S+)/; -my sub is_nbd { +sub is_nbd { my ($drive) = @_; return 1 if $drive->{file} =~ $NBD_TCP_PATH_RE_3; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel