[pve-devel] [PATCH pve-storage 3/4] lvmplugin: add thin volume support for LVM external snapshots

DERUMIER, Alexandre alexandre.derumier at groupe-cyllene.com
Wed Nov 12 16:42:37 CET 2025


>>
>>diff --git a/src/PVE/Storage/Common.pm b/src/PVE/Storage/Common.pm
>>index 222dc76..1e5d4c6 100644
>>--- a/src/PVE/Storage/Common.pm
>>+++ b/src/PVE/Storage/Common.pm
>>@@ -170,7 +170,7 @@ C<$options> currently allows setting the
>>C<preallocation> value.
>> =cut
>> 
>> sub qemu_img_create_qcow2_backed {
>>-    my ($path, $backing_path, $backing_format, $options) = @_;
>>+    my ($path, $backing_path, $backing_format, $options, $thin) =
>>@_;
>> 
>>     my $cmd = [
>>         '/usr/bin/qemu-img',
>>@@ -188,7 +188,7 @@ sub qemu_img_create_qcow2_backed {
>>     my $opts = ['extended_l2=on', 'cluster_size=128k'];
>> 
>>     push @$opts, "preallocation=$options->{preallocation}"
>>-        if defined($options->{preallocation});
>>+        if defined($options->{preallocation}) && !$thin;
>>     push @$cmd, '-o', join(',', @$opts) if @$opts > 0;
>> 
>>     run_command($cmd, errmsg => "unable to create image");
>>diff --git a/src/PVE/Storage/LVMPlugin.pm
>>b/src/PVE/Storage/LVMPlugin.pm
>>index 0416c9e..dc5e648 100644
>>--- a/src/PVE/Storage/LVMPlugin.pm
>>+++ b/src/PVE/Storage/LVMPlugin.pm
>>@@ -575,7 +575,7 @@ sub lvrename {
>> }
>> 
>> my sub lvm_qcow2_format {
>>-    my ($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size)
>>= @_;
>>+    my ($class, $storeid, $scfg, $name, $fmt, $backing_snap, $size,
>>$thin) = @_;
>> 
>>     $class->activate_volume($storeid, $scfg, $name);
>>     my $path = $class->path($scfg, $name, $storeid);
>>@@ -585,7 +585,9 @@ my sub lvm_qcow2_format {
>>     };
>>     if ($backing_snap) {
>>         my $backing_volname = get_snap_name($class, $name,
>>$backing_snap);
>>-        PVE::Storage::Common::qemu_img_create_qcow2_backed($path,
>>$backing_volname, $fmt, $options);
>>+        PVE::Storage::Common::qemu_img_create_qcow2_backed(
>>+            $path, $backing_volname, $fmt, $options, $thin,
>>+        );

don't add a new $thin parameter ,

"
    my $options = {
        preallocation =>
PVE::Storage::Plugin::preallocation_cmd_opt($scfg, $fmt),
    };
"

should return the correct preallocation (or no preallocation),  based
on $scfg . (where you should declare the "thin" option, and not drive)







More information about the pve-devel mailing list