all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC storage 2/2] lvm plugin: disallow disabling 'snapshot-as-volume-chain' while a qcow2 image exists
Date: Wed,  8 Oct 2025 17:11:32 +0200	[thread overview]
Message-ID: <20251008151140.127355-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20251008151140.127355-1-f.ebner@proxmox.com>

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@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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


      parent reply	other threads:[~2025-10-08 15:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08 15:11 [pve-devel] [RFC storage 0/2] close #6669: plugin api: introduce on_update_hook_full() method Fiona Ebner
2025-10-08 15:11 ` [pve-devel] [RFC storage 1/2] " Fiona Ebner
2025-10-08 15:11 ` Fiona Ebner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251008151140.127355-3-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal