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 4BCF61FF16B for ; Tue, 1 Jul 2025 17:45:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9D6F2A7D8; Tue, 1 Jul 2025 17:42:13 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Tue, 1 Jul 2025 17:41:08 +0200 Message-ID: <20250701154117.434512-49-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 48/49] partially fix #3227: ensure that target image for mirror has the same size for EFI disks 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" 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 --- 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 919bc756..00749c29 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