[pve-devel] [RFC storage 2/2] lvm plugin: disallow disabling 'snapshot-as-volume-chain' while a qcow2 image exists

Fiona Ebner f.ebner at proxmox.com
Wed Oct 8 17:11:32 CEST 2025


There are multiple reasons to disallow disabling
'snapshot-as-volume-chain' while a qcow2 image exists:

1. The list of allowed formats depends on 'snapshot-as-volume-chain'.
2. Snapshot functionality is broken. This includes creating snapshots,
   but also rollback, which removes the current volume and then fails.
3. There already is coupling between having qcow2 on LVM and having
   'snapshot-as-volume-chain' enabled. For example, the
   'discard-no-unref' option is required for qcow2 on LVM, but
   qemu-server only checks for 'snapshot-as-volume-chain' to avoid
   hard-coding LVM. Another one is that volume_qemu_snapshot_method()
   returns 'mixed' when the format is qcow2 even when
   'snapshot-as-volume-chain' is disabled. Hunting down these corner
   cases just to make it easier to disable does not seem to be worth
   it, considering there's already 1. and 2. as reasons too.
4. There might be other similar issues that have not surfaced yet,
   because disabling the feature while qcow2 is present is essentially
   untested and very uncommon.

For file-based storages, the 'snapshot-as-volume-chain' property is
already fixed, i.e. is determined upon storage creation.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 src/PVE/Storage/LVMPlugin.pm | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 0416c9e..c884941 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -439,6 +439,25 @@ sub on_add_hook {
     return;
 }
 
+sub on_update_hook_full {
+    my ($class, $storeid, $scfg, $update, $delete, $sensitive) = @_;
+
+    if (
+        $scfg->{'snapshot-as-volume-chain'} # currently set
+        && ( # and won't be set after update, because:
+            (
+                defined($update->{'snapshot-as-volume-chain'})
+                && !$update->{'snapshot-as-volume-chain'}
+            ) # explicitly set to disabled
+            || grep { $_ eq 'snapshot-as-volume-chain' } $delete->@* # or deleted
+        )
+    ) {
+        my $images = $class->list_images($storeid, $scfg, undef, undef, undef);
+        die "$storeid - cannot disable 'snapshot-as-volume-chain' while a qcow2 image exists\n"
+            if grep { $_->{format} eq 'qcow2' } $images->@*;
+    }
+}
+
 sub parse_volname {
     my ($class, $volname) = @_;
 
-- 
2.47.3





More information about the pve-devel mailing list