X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PVE%2FStorage.pm;h=ace3340179327a252c266c71a52e4c9f463653f1;hb=ffc31266da8854be3e9063d5f44dcbd1decbe4f9;hp=19f675d5bd2045ead97c23b56c35fb7bce73e57b;hpb=26d7314be088c9ddba9fd669fe0eab40461b7ead;p=pve-storage.git diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 19f675d..ace3340 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -37,7 +37,6 @@ use PVE::Storage::ISCSIDirectPlugin; use PVE::Storage::GlusterfsPlugin; use PVE::Storage::ZFSPoolPlugin; use PVE::Storage::ZFSPlugin; -use PVE::Storage::DRBDPlugin; use PVE::Storage::PBSPlugin; # Storage API version. Increment it on changes in storage API interface. @@ -60,7 +59,6 @@ PVE::Storage::ISCSIDirectPlugin->register(); PVE::Storage::GlusterfsPlugin->register(); PVE::Storage::ZFSPoolPlugin->register(); PVE::Storage::ZFSPlugin->register(); -PVE::Storage::DRBDPlugin->register(); PVE::Storage::PBSPlugin->register(); # load third-party plugins @@ -75,10 +73,8 @@ if ( -d '/usr/share/perl5/PVE/Storage/Custom' ) { require $file; # Check perl interface: - die "not derived from PVE::Storage::Plugin\n" - if !$modname->isa('PVE::Storage::Plugin'); - die "does not provide an api() method\n" - if !$modname->can('api'); + die "not derived from PVE::Storage::Plugin\n" if !$modname->isa('PVE::Storage::Plugin'); + die "does not provide an api() method\n" if !$modname->can('api'); # Check storage API version and that file is really storage plugin. my $version = $modname->api(); die "implements an API version newer than current ($version > " . APIVER . ")\n" @@ -86,11 +82,11 @@ if ( -d '/usr/share/perl5/PVE/Storage/Custom' ) { my $min_version = (APIVER - APIAGE); die "API version too old, please update the plugin ($version < $min_version)\n" if $version < $min_version; + # all OK, do import and register (i.e., "use") import $file; $modname->register(); - # If we got this far and the API version is not the same, make some - # noise: + # If we got this far and the API version is not the same, make some noise: warn "Plugin \"$modname\" is implementing an older storage API, an upgrade is recommended\n" if $version != APIVER; }; @@ -127,7 +123,7 @@ sub lock_storage_config { } } -# FIXME remove maxfiles for PVE 7.0 +# FIXME remove maxfiles for PVE 8.0 or PVE 9.0 my $convert_maxfiles_to_prune_backups = sub { my ($scfg) = @_; @@ -194,7 +190,7 @@ sub storage_check_enabled { # storage_can_replicate: # return true if storage supports replication -# (volumes alocated with vdisk_alloc() has replication feature) +# (volumes allocated with vdisk_alloc() has replication feature) sub storage_can_replicate { my ($cfg, $storeid, $format) = @_; @@ -609,22 +605,22 @@ sub path { } sub abs_filesystem_path { - my ($cfg, $volid) = @_; + my ($cfg, $volid, $allow_blockdev) = @_; my $path; if (parse_volume_id ($volid, 1)) { activate_volumes($cfg, [ $volid ]); $path = PVE::Storage::path($cfg, $volid); } else { - if (-f $volid) { + if (-f $volid || ($allow_blockdev && -b $volid)) { my $abspath = abs_path($volid); if ($abspath && $abspath =~ m|^(/.+)$|) { $path = $1; # untaint any path } } } - - die "can't find file '$volid'\n" if !($path && -f $path); + die "can't find file '$volid'\n" + if !($path && (-f $path || ($allow_blockdev && -b $path))); return $path; } @@ -932,13 +928,13 @@ sub vdisk_free { } sub vdisk_list { - my ($cfg, $storeid, $vmid, $vollist) = @_; + my ($cfg, $storeid, $vmid, $vollist, $ctype) = @_; my $ids = $cfg->{ids}; storage_check_enabled($cfg, $storeid) if ($storeid); - my $res = {}; + my $res = $storeid ? { $storeid => [] } : {}; # prepare/activate/refresh all storages @@ -955,6 +951,7 @@ sub vdisk_list { next if $storeid && $storeid ne $sid; next if !storage_check_enabled($cfg, $sid, undef, 1); my $content = $ids->{$sid}->{content}; + next if defined($ctype) && !$content->{$ctype}; next if !($content->{rootdir} || $content->{images}); push @$storage_list, $sid; } @@ -964,10 +961,8 @@ sub vdisk_list { activate_storage_list($cfg, $storage_list, $cache); - # FIXME PVE 7.0: only scan storages with the correct content types - foreach my $sid (keys %$ids) { + for my $sid ($storage_list->@*) { next if $storeid && $storeid ne $sid; - next if !storage_check_enabled($cfg, $sid, undef, 1); my $scfg = $ids->{$sid}; my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); @@ -1627,6 +1622,8 @@ sub prune_backups { $keep = PVE::JSONSchema::parse_property_string('prune-backups', $scfg->{'prune-backups'}); } + activate_storage($cfg, $storeid); + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); return $plugin->prune_backups($scfg, $storeid, $keep, $vmid, $type, $dryrun, $logfunc); } @@ -1849,7 +1846,7 @@ sub get_bandwidth_limit { my ($operation, $storage_list, $override) = @_; # called for each limit (global, per-storage) with the 'default' and the - # $operation limit and should udpate $override for every limit affecting + # $operation limit and should update $override for every limit affecting # us. my $use_global_limits = 0; my $apply_limit = sub {