all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH FOLLOW-UP storage 02/10] common: fix qemu_img_resize
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 03/10] plugin: volume_export: don't allow export of external snapshots Alexandre Derumier via pve-devel
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 4484 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 02/10] common: fix qemu_img_resize
Date: Tue, 15 Jul 2025 07:26:35 +0200
Message-ID: <20250715052643.1182073-2-alexandre.derumier@groupe-cyllene.com>

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/Common.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Storage/Common.pm b/src/PVE/Storage/Common.pm
index 71d123a..746a262 100644
--- a/src/PVE/Storage/Common.pm
+++ b/src/PVE/Storage/Common.pm
@@ -245,7 +245,7 @@ sub qemu_img_measure {
 
 =head3 qemu_img_resize
 
-    qemu_img_resize($scfg, $path, $format, $size, $preallocation, $timeout)
+    qemu_img_resize($path, $format, $size, $preallocation, $timeout)
 
 Resize a qemu image C<$path> with format C<$format> to a target Kb size C<$size>.
 Default timeout C<$timeout> is 10s if not specified.
@@ -254,7 +254,7 @@ C<$preallocation> allows to specify the preallocation option for the resize oper
 =cut
 
 sub qemu_img_resize {
-    my ($scfg, $path, $format, $size, $preallocation, $timeout) = @_;
+    my ($path, $format, $size, $preallocation, $timeout) = @_;
 
     die "format is missing" if !$format;
 
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [pve-devel] [PATCH FOLLOW-UP storage 03/10] plugin: volume_export: don't allow export of external snapshots
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 02/10] common: fix qemu_img_resize Alexandre Derumier via pve-devel
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 04/10] lvmplugin: alloc_snap_image: die if file_size_info return empty size Alexandre Derumier via pve-devel
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 3859 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 03/10] plugin: volume_export: don't allow export of external snapshots
Date: Tue, 15 Jul 2025 07:26:36 +0200
Message-ID: <20250715052643.1182073-3-alexandre.derumier@groupe-cyllene.com>

not yet implemented

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/Plugin.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index aee145f..06d258e 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -2010,6 +2010,9 @@ sub volume_export {
     my ($class, $scfg, $storeid, $fh, $volname, $format, $snapshot, $base_snapshot, $with_snapshots)
         = @_;
 
+    die "cannot export volumes together with their snapshots in $class\n"
+        if $with_snapshots && $scfg->{'external-snapshots'};
+
     my $err_msg = "volume export format $format not available for $class\n";
     if ($scfg->{path} && !defined($snapshot) && !defined($base_snapshot)) {
         my ($file) = $class->path($scfg, $volname, $storeid) or die $err_msg;
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [pve-devel] [PATCH FOLLOW-UP storage 04/10] lvmplugin: alloc_snap_image: die if file_size_info return empty size
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 02/10] common: fix qemu_img_resize Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 03/10] plugin: volume_export: don't allow export of external snapshots Alexandre Derumier via pve-devel
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 05/10] lvmplugin: snapshot: use relative path for backing image Alexandre Derumier via pve-devel
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 4267 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 04/10] lvmplugin: alloc_snap_image: die if file_size_info return empty size
Date: Tue, 15 Jul 2025 07:26:37 +0200
Message-ID: <20250715052643.1182073-4-alexandre.derumier@groupe-cyllene.com>

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/LVMPlugin.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 54070d1..cb5fd37 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -668,6 +668,8 @@ my sub alloc_snap_image {
 
     #we need to use same size than the backing image qcow2 virtual-size
     my $size = PVE::Storage::Plugin::file_size_info($path, 5, $format);
+    die "file_size_info on '$volname' failed\n" if !defined($size);
+
     $size = $size / 1024; #we use kb in lvcreate
 
     alloc_lvm_image($class, $storeid, $scfg, $vmid, $format, $volname, $size, $backing_snap);
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [pve-devel] [PATCH FOLLOW-UP storage 05/10] lvmplugin: snapshot: use relative path for backing image
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
                   ` (2 preceding siblings ...)
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 04/10] lvmplugin: alloc_snap_image: die if file_size_info return empty size Alexandre Derumier via pve-devel
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 06/10] plugin|lvmplugin: don't allow volume rename if external snapshots exist Alexandre Derumier via pve-devel
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 4482 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 05/10] lvmplugin: snapshot: use relative path for backing image
Date: Tue, 15 Jul 2025 07:26:38 +0200
Message-ID: <20250715052643.1182073-5-alexandre.derumier@groupe-cyllene.com>

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/LVMPlugin.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index cb5fd37..9aadbc2 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -583,8 +583,8 @@ my sub lvm_qcow2_format {
         preallocation => PVE::Storage::Plugin::preallocation_cmd_opt($scfg, $fmt),
     };
     if ($backing_snap) {
-        my $backing_path = $class->path($scfg, $name, $storeid, $backing_snap);
-        PVE::Storage::Common::qemu_img_create_qcow2_backed($path, $backing_path, $fmt, $options);
+        my $backing_volname = get_snap_name($class, $name, $backing_snap);
+        PVE::Storage::Common::qemu_img_create_qcow2_backed($path, $backing_volname, $fmt, $options);
     } else {
         PVE::Storage::Common::qemu_img_create($fmt, $size, $path, $options);
     }
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [pve-devel] [PATCH FOLLOW-UP storage 06/10] plugin|lvmplugin: don't allow volume rename if external snapshots exist.
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
                   ` (3 preceding siblings ...)
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 05/10] lvmplugin: snapshot: use relative path for backing image Alexandre Derumier via pve-devel
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 07/10] lvmplugin: add volume_snapshot_info Alexandre Derumier via pve-devel
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 4595 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 06/10] plugin|lvmplugin: don't allow volume rename if external snapshots exist.
Date: Tue, 15 Jul 2025 07:26:39 +0200
Message-ID: <20250715052643.1182073-6-alexandre.derumier@groupe-cyllene.com>

Just to safe, as this is already check higher in the stack.

Technically, it's possible to implement snapshot file renaming,
and update backing_file info with "qemu-img rebase -u".

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/LVMPlugin.pm | 6 ++++++
 src/PVE/Storage/Plugin.pm    | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 9aadbc2..8a61bc5 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -1233,6 +1233,12 @@ sub rename_volume {
     my (
         undef, $source_image, $source_vmid, $base_name, $base_vmid, undef, $format,
     ) = $class->parse_volname($source_volname);
+
+    if ($format eq 'qcow2') {
+        my $snapshots = $class->volume_snapshot_info($scfg, $storeid, $source_volname);
+        die "we can't rename volume if external snapshot exists" if $snapshots->{current}->{parent};
+    }
+
     $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid, $format)
         if !$target_volname;
 
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 06d258e..8ea62e4 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -2175,6 +2175,11 @@ sub rename_volume {
     die "not implemented in storage plugin '$class'\n" if $class->can('api') && $class->api() < 10;
     die "no path found\n" if !$scfg->{path};
 
+    if ($scfg->{'external-snapshots'}) {
+        my $snapshots = $class->volume_snapshot_info($scfg, $storeid, $source_volname);
+        die "we can't rename volume if external snapshot exists" if $snapshots->{current}->{parent};
+    }
+
     my (
         undef, $source_image, $source_vmid, $base_name, $base_vmid, undef, $format,
     ) = $class->parse_volname($source_volname);
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [pve-devel] [PATCH FOLLOW-UP storage 07/10] lvmplugin: add volume_snapshot_info
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
                   ` (4 preceding siblings ...)
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 06/10] plugin|lvmplugin: don't allow volume rename if external snapshots exist Alexandre Derumier via pve-devel
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 08/10] plugin: lvmplugin: add parse_snap_name Alexandre Derumier via pve-devel
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 8998 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 07/10] lvmplugin: add volume_snapshot_info
Date: Tue, 15 Jul 2025 07:26:40 +0200
Message-ID: <20250715052643.1182073-7-alexandre.derumier@groupe-cyllene.com>

and remove public methods:
get_snapname_from_path
get_snap_volname

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/LVMPlugin.pm | 76 ++++++++++++++++++++++++++----------
 src/PVE/Storage/Plugin.pm    | 41 ++++++++-----------
 2 files changed, 73 insertions(+), 44 deletions(-)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 8a61bc5..0e2c38c 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -443,20 +443,6 @@ sub parse_volname {
     die "unable to parse lvm volume name '$volname'\n";
 }
 
-#return snapshot name from a file path
-sub get_snapname_from_path {
-    my ($class, $volname, $path) = @_;
-
-    my $basepath = basename($path);
-    my $name = ($volname =~ s/\.[^.]+$//r);
-    if ($basepath =~ m/^snap_${name}_(.*)\.qcow2$/) {
-        return $1;
-    } elsif ($basepath eq $volname) {
-        return 'current';
-    }
-    return undef;
-}
-
 my sub get_snap_name {
     my ($class, $volname, $snapname) = @_;
 
@@ -472,12 +458,6 @@ my sub get_snap_name {
     }
 }
 
-sub get_snap_volname {
-    my ($class, $volname, $snapname) = @_;
-
-    return get_snap_name($class, $volname, $snapname);
-}
-
 sub filesystem_path {
     my ($class, $scfg, $volname, $snapname) = @_;
 
@@ -787,6 +767,62 @@ sub status {
     return undef;
 }
 
+sub volume_snapshot_info {
+    my ($class, $scfg, $storeid, $volname) = @_;
+
+    my $get_snapname_from_path = sub {
+        my ($volname, $path) = @_;
+
+        my $basepath = basename($path);
+        my $name = ($volname =~ s/\.[^.]+$//r);
+        if ($basepath =~ m/^snap_${name}_(.*)\.qcow2$/) {
+            return $1;
+        } elsif ($basepath eq $volname) {
+            return 'current';
+        }
+        return undef;
+    };
+
+    my $path = $class->filesystem_path($scfg, $volname);
+    my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) =
+        $class->parse_volname($volname);
+
+    my $json = PVE::Storage::Common::qemu_img_info($path, undef, 10, 1);
+    die "failed to query file information with qemu-img\n" if !$json;
+    my $json_decode = eval { decode_json($json) };
+    if ($@) {
+        die "Can't decode qemu snapshot list. Invalid JSON: $@\n";
+    }
+    my $info = {};
+    my $order = 0;
+    return $info if ref($json_decode) ne 'ARRAY';
+
+    #no snapshot or external  snapshots is an arrayref
+    my $snapshots = $json_decode;
+    for my $snap (@$snapshots) {
+        my $snapfile = $snap->{filename};
+        my $snapname = $get_snapname_from_path->($volname, $snapfile);
+        #not a proxmox snapshot
+        next if !$snapname;
+
+        my $snapvolname = get_snap_name($class, $volname, $snapname);
+
+        $info->{$snapname}->{order} = $order;
+        $info->{$snapname}->{file} = $snapfile;
+        $info->{$snapname}->{volname} = "$snapvolname";
+        $info->{$snapname}->{volid} = "$storeid:$snapvolname";
+
+        my $parentfile = $snap->{'backing-filename'};
+        if ($parentfile) {
+            my $parentname = $get_snapname_from_path->($volname, $parentfile);
+            $info->{$snapname}->{parent} = $parentname;
+            $info->{$parentname}->{child} = $snapname;
+        }
+        $order++;
+    }
+    return $info;
+}
+
 sub activate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 8ea62e4..aafb13c 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -1718,27 +1718,6 @@ sub status {
     return ($res->{total}, $res->{avail}, $res->{used}, 1);
 }
 
-sub get_snap_volname {
-    my ($class, $volname, $snapname) = @_;
-
-    my $vmid = ($class->parse_volname($volname))[2];
-    my $name = get_snap_name($class, $volname, $snapname);
-    return "$vmid/$name";
-}
-
-#return snapshot name from a file path
-sub get_snapname_from_path {
-    my ($class, $volname, $path) = @_;
-
-    my $basepath = basename($path);
-    if ($basepath =~ m/^snap-(.*)-vm(.*)$/) {
-        return $1;
-    } elsif ($basepath eq basename($volname)) {
-        return 'current';
-    }
-    return undef;
-}
-
 # Returns a hash with the snapshot names as keys and the following data:
 # id        - Unique id to distinguish different snapshots even if the have the same name.
 # timestamp - Creation time of the snapshot (seconds since epoch).
@@ -1746,6 +1725,18 @@ sub get_snapname_from_path {
 sub volume_snapshot_info {
     my ($class, $scfg, $storeid, $volname) = @_;
 
+    my $get_snapname_from_path = sub {
+        my ($volname, $path) = @_;
+
+        my $basepath = basename($path);
+        if ($basepath =~ m/^snap-(.*)-vm(.*)$/) {
+            return $1;
+        } elsif ($basepath eq basename($volname)) {
+            return 'current';
+        }
+        return undef;
+    };
+
     my $path = $class->filesystem_path($scfg, $volname);
     my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) =
         $class->parse_volname($volname);
@@ -1772,11 +1763,13 @@ sub volume_snapshot_info {
         my $snapshots = $json_decode;
         for my $snap (@$snapshots) {
             my $snapfile = $snap->{filename};
-            my $snapname = $class->get_snapname_from_path($volname, $snapfile);
+            my $snapname = $get_snapname_from_path->($volname, $snapfile);
             #not a proxmox snapshot
             next if !$snapname;
 
-            my $snapvolname = $class->get_snap_volname($volname, $snapname);
+            my $snapvolname = get_snap_name($class, $volname, $snapname);
+            $snapvolname = "$vmid/$snapvolname";
+
             $info->{$snapname}->{order} = $order;
             $info->{$snapname}->{file} = $snapfile;
             $info->{$snapname}->{volname} = "$snapvolname";
@@ -1785,7 +1778,7 @@ sub volume_snapshot_info {
 
             my $parentfile = $snap->{'backing-filename'};
             if ($parentfile) {
-                my $parentname = $class->get_snapname_from_path($volname, $parentfile);
+                my $parentname = $get_snapname_from_path->($volname, $parentfile);
                 $info->{$snapname}->{parent} = $parentname;
                 $info->{$parentname}->{child} = $snapname;
             }
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [pve-devel] [PATCH FOLLOW-UP storage 08/10] plugin: lvmplugin: add parse_snap_name
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
                   ` (5 preceding siblings ...)
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 07/10] lvmplugin: add volume_snapshot_info Alexandre Derumier via pve-devel
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 09/10] plugin : improve parse_namedir warning Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 10/10] lvmplugin: add external-snapshots option && forbid creation of qcow2 volumes without it Alexandre Derumier via pve-devel
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 4948 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 08/10] plugin: lvmplugin: add parse_snap_name
Date: Tue, 15 Jul 2025 07:26:41 +0200
Message-ID: <20250715052643.1182073-8-alexandre.derumier@groupe-cyllene.com>

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/LVMPlugin.pm | 17 ++++++++++++-----
 src/PVE/Storage/Plugin.pm    | 17 +++++++++++++----
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 0e2c38c..6e77eb3 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -458,6 +458,14 @@ my sub get_snap_name {
     }
 }
 
+my sub parse_snap_name {
+    my ($name) = @_;
+
+    if ($name =~ m/^snap_\S+_(.*)\.qcow2$/) {
+        return $1;
+    }
+}
+
 sub filesystem_path {
     my ($class, $scfg, $volname, $snapname) = @_;
 
@@ -773,11 +781,10 @@ sub volume_snapshot_info {
     my $get_snapname_from_path = sub {
         my ($volname, $path) = @_;
 
-        my $basepath = basename($path);
-        my $name = ($volname =~ s/\.[^.]+$//r);
-        if ($basepath =~ m/^snap_${name}_(.*)\.qcow2$/) {
-            return $1;
-        } elsif ($basepath eq $volname) {
+        my $name = basename($path);
+        if (my $snapname = parse_snap_name($name)) {
+            return $snapname;
+        } elsif ($name eq $volname) {
             return 'current';
         }
         return undef;
diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index aafb13c..59ffa5e 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -779,6 +779,14 @@ my sub get_snap_name {
     return $name;
 }
 
+my sub parse_snap_name {
+    my ($name) = @_;
+
+    if ($name =~ m/^snap-(.*)-vm(.*)$/) {
+        return $1;
+    }
+}
+
 sub filesystem_path {
     my ($class, $scfg, $volname, $snapname) = @_;
 
@@ -1728,10 +1736,11 @@ sub volume_snapshot_info {
     my $get_snapname_from_path = sub {
         my ($volname, $path) = @_;
 
-        my $basepath = basename($path);
-        if ($basepath =~ m/^snap-(.*)-vm(.*)$/) {
-            return $1;
-        } elsif ($basepath eq basename($volname)) {
+        my $name = basename($path);
+
+        if (my $snapname = parse_snap_name($name)) {
+            return $snapname;
+        } elsif ($name eq basename($volname)) {
             return 'current';
         }
         return undef;
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [pve-devel] [PATCH FOLLOW-UP storage 09/10] plugin : improve parse_namedir warning
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
                   ` (6 preceding siblings ...)
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 08/10] plugin: lvmplugin: add parse_snap_name Alexandre Derumier via pve-devel
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 10/10] lvmplugin: add external-snapshots option && forbid creation of qcow2 volumes without it Alexandre Derumier via pve-devel
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 3561 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 09/10] plugin : improve parse_namedir warning
Date: Tue, 15 Jul 2025 07:26:42 +0200
Message-ID: <20250715052643.1182073-9-alexandre.derumier@groupe-cyllene.com>

display the volname
skip warning for external snapshot name

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/Plugin.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 59ffa5e..439e4c3 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -694,7 +694,7 @@ sub parse_name_dir {
         my $isbase = $2 eq 'base-' ? $2 : undef;
         return ($1, $4, $isbase); # (name, format, isBase)
     } elsif ($name =~ m!^((base-)?[^/\s]+\.(raw|qcow2|vmdk|subvol))$!) {
-        warn "this volume filename is not supported anymore\n";
+        warn "this volume name `$name` is not supported anymore\n" if !parse_snap_name($name);
     }
 
     die "unable to parse volume filename '$name'\n";
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [pve-devel] [PATCH FOLLOW-UP storage 10/10] lvmplugin: add external-snapshots option && forbid creation of qcow2 volumes without it
       [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
                   ` (7 preceding siblings ...)
  2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 09/10] plugin : improve parse_namedir warning Alexandre Derumier via pve-devel
@ 2025-07-15  5:26 ` Alexandre Derumier via pve-devel
  8 siblings, 0 replies; 9+ messages in thread
From: Alexandre Derumier via pve-devel @ 2025-07-15  5:26 UTC (permalink / raw)
  To: pve-devel; +Cc: Alexandre Derumier

[-- Attachment #1: Type: message/rfc822, Size: 3671 bytes --]

From: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH FOLLOW-UP storage 10/10] lvmplugin: add external-snapshots option && forbid creation of qcow2 volumes without it
Date: Tue, 15 Jul 2025 07:26:43 +0200
Message-ID: <20250715052643.1182073-10-alexandre.derumier@groupe-cyllene.com>

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
---
 src/PVE/Storage/LVMPlugin.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/PVE/Storage/LVMPlugin.pm b/src/PVE/Storage/LVMPlugin.pm
index 6e77eb3..1f5a5f1 100644
--- a/src/PVE/Storage/LVMPlugin.pm
+++ b/src/PVE/Storage/LVMPlugin.pm
@@ -399,6 +399,7 @@ sub options {
         base => { fixed => 1, optional => 1 },
         tagged_only => { optional => 1 },
         bwlimit => { optional => 1 },
+        'external-snapshots' => { optional => 1 },
     };
 }
 
@@ -603,6 +604,10 @@ my sub alloc_lvm_image {
 
     die "unsupported format '$fmt'" if $fmt ne 'raw' && $fmt ne 'qcow2';
 
+    die "external-snapshots option need to be enabled to use qcow2 format"
+        if $fmt eq 'qcow2'
+        && !$scfg->{'external-snapshots'};
+
     $class->parse_volname($name);
 
     my $vgs = lvm_vgs();
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-15  5:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20250715052643.1182073-1-alexandre.derumier@groupe-cyllene.com>
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 02/10] common: fix qemu_img_resize Alexandre Derumier via pve-devel
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 03/10] plugin: volume_export: don't allow export of external snapshots Alexandre Derumier via pve-devel
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 04/10] lvmplugin: alloc_snap_image: die if file_size_info return empty size Alexandre Derumier via pve-devel
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 05/10] lvmplugin: snapshot: use relative path for backing image Alexandre Derumier via pve-devel
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 06/10] plugin|lvmplugin: don't allow volume rename if external snapshots exist Alexandre Derumier via pve-devel
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 07/10] lvmplugin: add volume_snapshot_info Alexandre Derumier via pve-devel
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 08/10] plugin: lvmplugin: add parse_snap_name Alexandre Derumier via pve-devel
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 09/10] plugin : improve parse_namedir warning Alexandre Derumier via pve-devel
2025-07-15  5:26 ` [pve-devel] [PATCH FOLLOW-UP storage 10/10] lvmplugin: add external-snapshots option && forbid creation of qcow2 volumes without it Alexandre Derumier via pve-devel

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