[pve-devel] [PATCH storage 3/9] lvm plugin: implement get_formats() method

Fiona Ebner f.ebner at proxmox.com
Mon Jul 21 14:10:48 CEST 2025


As the alloc_lvm_image() helper asserts, qcow2 cannot be used as a
format without the 'snapshot-as-volume-chain' configuration option.
Therefore it is necessary to implement get_formats() and distinguish
based on the storage configuration.

In case the 'snapshot-as-volume-chain' option is set, qcow2 is even
preferred and thus declared the default format.

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

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 8be2a10..1690e97 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -405,6 +405,16 @@ sub options {
 
 # Storage implementation
 
+sub get_formats {
+    my ($class, $scfg, $storeid) = @_;
+
+    if ($scfg->{'snapshot-as-volume-chain'}) {
+        return { default => 'qcow2', valid => { 'qcow2' => 1, 'raw' => 1, } };
+    }
+
+    return { default => 'raw', valid => { 'raw' => 1 } };
+}
+
 sub on_add_hook {
     my ($class, $storeid, $scfg, %param) = @_;
 
-- 
2.47.2





More information about the pve-devel mailing list