From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 12A781FF0E5 for ; Wed, 12 Aug 2026 13:10:42 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 70C032157F; Wed, 12 Aug 2026 13:10:41 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server] cloud-init: activate volume early enough to fix regression with qcow2 on LVM Date: Wed, 12 Aug 2026 13:10:26 +0200 Message-ID: <20260812111035.84116-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1786533023517 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.907 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: J42IBLGHHKA7BLBJ4JCR2MMLSSD3EDNR X-Message-ID-Hash: J42IBLGHHKA7BLBJ4JCR2MMLSSD3EDNR X-MailFrom: f.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Since pve-storage commit 05032c5 ("fix #7811: storage: lvm: reject allocation on format and volume name mismatch") and its follow-ups, cloud-init disks are named with a '.qcow2' extension on LVM storages with snapshot-as-volume-chain enabled. This causes a regression, because volume_size_info() fails and returns undef when the qcow2 volume is not active. When the size cannot be determined, commit_cloudinit_disk() function assumes that the disk does not yet exist and tries to allocate new disk with the same name, which fails. [I] root@pve9a1 ~# qm start 100 failed to stat '/dev/lvm/vm-100-cloudinit.qcow2' Rounding up size to full physical extent 8.00 MiB lvcreate 'lvm/vm-100-cloudinit.qcow2' error: Logical Volume "vm-100-cloudinit.qcow2" already exists in volume group "lvm" Fix the issue by checking the existence/size with vdisk_list(), which also works for deactivated volumes. Activating the volume earlier is an alternative, but would need to be inside an eval block that silently ignores failure, since the volume might not exist yet, which should not be logged. And in case where the qcow2 on LVM volume does exist, but activation fails, there would be an attempt to allocate a new volume with the same name, which also seems less than ideal. So that approach is a bit hacky. Signed-off-by: Fiona Ebner --- src/PVE/QemuServer/Cloudinit.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/PVE/QemuServer/Cloudinit.pm b/src/PVE/QemuServer/Cloudinit.pm index c1311da8..5af6b608 100644 --- a/src/PVE/QemuServer/Cloudinit.pm +++ b/src/PVE/QemuServer/Cloudinit.pm @@ -39,7 +39,18 @@ sub commit_cloudinit_disk { my $scfg = PVE::Storage::storage_config($storecfg, $storeid); my $format = checked_volume_format($storecfg, $drive->{file}); - my $size = eval { PVE::Storage::volume_size_info($storecfg, $drive->{file}) }; + my $volumes = PVE::Storage::vdisk_list($storecfg, $storeid, $vmid, [$drive->{file}], 'images'); + if (scalar($volumes->{$storeid}->@*) > 1) { + # just to be sure, since this is the first caller with $vollist outside of the storage tests + print "bug: storage plugin for '$storeid' does not honor \$vollist for list_images()\n"; + } + my $size; + for my $volume_info ($volumes->{$storeid}->@*) { + next if $volume_info->{volid} ne $drive->{file}; + $size = $volume_info->{size} // $volume_info->{'approximate-size'}; + last; + } + if (!defined($size) || $size <= 0) { $volname =~ m/(vm-$vmid-cloudinit(.\Q$format\E)?)/; my $name = $1; -- 2.47.3