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 B49301FF0E9 for ; Thu, 16 Jul 2026 12:33:00 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 83BAA2143A; Thu, 16 Jul 2026 12:33:00 +0200 (CEST) From: Elias Huhsovitz To: pve-devel@lists.proxmox.com Subject: [PATCH storage] fix #7811: storage: lvm: reject allocation on format and volume name mismatch Date: Thu, 16 Jul 2026 12:32:43 +0200 Message-ID: <20260716103243.61836-1-e.huhsovitz@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: 1784197958694 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.258 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_LOW -0.7 Sender listed at https://www.dnswl.org/, low 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: TL6M62YPH3PQV6DTRW67MI7SMSNFX24I X-Message-ID-Hash: TL6M62YPH3PQV6DTRW67MI7SMSNFX24I X-MailFrom: e.huhsovitz@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 CC: Elias Huhsovitz X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When users allocate a new volume via the API and request a specific format (like 'qcow2'), but provide a volume name without the corresponding extension (like 'vm-100-disk-0'), the generic API validation misses the inconsistency. This occurs because standard LVM raw volumes do not use file extensions. The LVMPlugin ignored this mismatch. It created a raw logical volume and logged a misleading "formatting as qcow2" message. This resulted in a confusing state where the storage lists the volume as 'raw', but the underlying block device contains a 'qcow2' image. To fix this, add a new file-private subroutine, `verify_volname_format`, to the LVM plugin. This subroutine compares the requested format with the format implied by the volume name. If they differ, the plugin rejects the allocation and provides a hint to correct the volume name. Signed-off-by: Elias Huhsovitz --- src/PVE/Storage/LVMPlugin.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm index a313ecc..3be833e 100644 --- a/src/PVE/Storage/LVMPlugin.pm +++ b/src/PVE/Storage/LVMPlugin.pm @@ -738,12 +738,36 @@ my sub alloc_lvm_image { } +my %LVM_FORMAT_EXTENSIONS = ( + raw => '', + qcow2 => 'qcow2', +); + +my sub verify_volname_format { + my ($class, $name, $fmt) = @_; + + my $expected_ext = $LVM_FORMAT_EXTENSIONS{$fmt}; + return if !defined($expected_ext); + + my (undef, undef, undef, undef, undef, undef, $parsed_fmt) = $class->parse_volname($name); + + return if $fmt eq $parsed_fmt; + + my $base_name = $name =~ s/\.[^.]+$//r; + my $suggested_name = $expected_ext ? "$base_name.$expected_ext" : $base_name; + + die "volume name '$name' does not match requested format '$fmt' " + . "(did you mean '$suggested_name'?)\n"; +} + sub alloc_image { my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_; $name = $class->find_free_diskname($storeid, $scfg, $vmid, $fmt) if !$name; + verify_volname_format($class, $name, $fmt); + alloc_lvm_image($class, $storeid, $scfg, $vmid, $fmt, $name, $size); return $name; -- 2.47.3