]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage.pm
prune mark: preserve additional information for the keep-all case
[pve-storage.git] / PVE / Storage.pm
index 7b319fe2ebde6578bcd9ff99a20718ebf77a8700..223fbb5b4e94cfc6fe3823507dd234c116012095 100755 (executable)
@@ -41,11 +41,11 @@ use PVE::Storage::PBSPlugin;
 use PVE::Storage::BTRFSPlugin;
 
 # Storage API version. Increment it on changes in storage API interface.
-use constant APIVER => 9;
+use constant APIVER => 10;
 # Age is the number of versions we're backward compatible with.
 # This is like having 'current=APIVER' and age='APIAGE' in libtool,
 # see https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
-use constant APIAGE => 0;
+use constant APIAGE => 1;
 
 # load standard plugins
 PVE::Storage::DirPlugin->register();
@@ -103,7 +103,7 @@ PVE::Storage::Plugin->init();
 
 our $iso_extension_re = qr/\.(?:iso|img)/i;
 
-our $vztmpl_extension_re = qr/\.tar\.([gx]z)/i;
+our $vztmpl_extension_re = qr/\.tar\.(gz|xz|zst)/i;
 
 #  PVE::Storage utility functions
 
@@ -215,24 +215,24 @@ sub file_size_info {
     return PVE::Storage::Plugin::file_size_info($filename, $timeout);
 }
 
-sub get_volume_notes {
-    my ($cfg, $volid, $timeout) = @_;
+sub get_volume_attribute {
+    my ($cfg, $volid, $attribute) = @_;
 
     my ($storeid, $volname) = parse_volume_id($volid);
     my $scfg = storage_config($cfg, $storeid);
     my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
 
-    return $plugin->get_volume_notes($scfg, $storeid, $volname, $timeout);
+    return $plugin->get_volume_attribute($scfg, $storeid, $volname, $attribute);
 }
 
-sub update_volume_notes {
-    my ($cfg, $volid, $notes, $timeout) = @_;
+sub update_volume_attribute {
+    my ($cfg, $volid, $attribute, $value) = @_;
 
     my ($storeid, $volname) = parse_volume_id($volid);
     my $scfg = storage_config($cfg, $storeid);
     my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
 
-    $plugin->update_volume_notes($scfg, $storeid, $volname, $notes, $timeout);
+    return $plugin->update_volume_attribute($scfg, $storeid, $volname, $attribute, $value);
 }
 
 sub volume_size_info {
@@ -269,13 +269,13 @@ sub volume_resize {
 }
 
 sub volume_rollback_is_possible {
-    my ($cfg, $volid, $snap) = @_;
+    my ($cfg, $volid, $snap, $blockers) = @_;
 
     my ($storeid, $volname) = parse_volume_id($volid, 1);
     if ($storeid) {
         my $scfg = storage_config($cfg, $storeid);
         my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
-        return $plugin->volume_rollback_is_possible($scfg, $storeid, $volname, $snap);
+        return $plugin->volume_rollback_is_possible($scfg, $storeid, $volname, $snap, $blockers);
     } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
         die "snapshot rollback file/device '$volid' is not possible\n";
     } else {
@@ -371,20 +371,13 @@ sub volume_has_feature {
     }
 }
 
-sub volume_snapshot_list {
+sub volume_snapshot_info {
     my ($cfg, $volid) = @_;
 
-    my ($storeid, $volname) = parse_volume_id($volid, 1);
-    if ($storeid) {
-       my $scfg = storage_config($cfg, $storeid);
-       my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
-       return $plugin->volume_snapshot_list($scfg, $storeid, $volname);
-    } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
-       die "send file/device '$volid' is not possible\n";
-    } else {
-       die "unable to parse volume ID '$volid'\n";
-    }
-    # return an empty array if dataset does not exist.
+    my ($storeid, $volname) = parse_volume_id($volid);
+    my $scfg = storage_config($cfg, $storeid);
+    my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+    return $plugin->volume_snapshot_info($scfg, $storeid, $volname);
 }
 
 sub get_image_dir {
@@ -1670,6 +1663,8 @@ sub prune_mark_backup_group {
 
     if ($keep->{'keep-all'} || scalar(@positive_opts) == 0) {
        foreach my $prune_entry (@{$backup_group}) {
+           # preserve additional information like 'protected'
+           next if $prune_entry->{mark} && $prune_entry->{mark} ne 'remove';
            $prune_entry->{mark} = 'keep';
        }
        return;