public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH v2 qemu-server] cloud-init: query volume size via vdisk_list() to fix regression with qcow2 on LVM
@ 2026-08-12 11:12 Fiona Ebner
  0 siblings, 0 replies; only message in thread
From: Fiona Ebner @ 2026-08-12 11:12 UTC (permalink / raw)
  To: pve-devel

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.

 # 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 <f.ebner@proxmox.com>
---

Changes in v2:
* don't include full shell prompt in commit message
* fix commit title

 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





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-12 11:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 11:12 [PATCH v2 qemu-server] cloud-init: query volume size via vdisk_list() to fix regression with qcow2 on LVM Fiona Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal