[pve-devel] [PATCH v3 manager 1/4] vzdump: storage info: move out activate storage call

Fabian Ebner f.ebner at proxmox.com
Thu Mar 11 10:22:05 CET 2021


Otherwise storage_info() cannot be used for (at least) PBS storages from an API
call without 'protected => 1', because the password cannot be read from
'/etc/pve/priv'. Note that the function itself does not need the storage to be
active, because it only uses storage_config() and get_backup_dir().

AFAICT new() is the only existing user of this function and can be responsible
for activating the storage itself.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

New in v3

 PVE/VZDump.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 02858d8e..fb4c8bad 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -106,8 +106,6 @@ sub storage_info {
     die "can't use storage '$storage' for backups - wrong content type\n"
 	if (!$scfg->{content}->{backup});
 
-    PVE::Storage::activate_storage($cfg, $storage);
-
     my $info = {
 	scfg => $scfg,
     };
@@ -505,6 +503,13 @@ sub new {
     my $errors = '';
 
     if ($opts->{storage}) {
+	my $storage_cfg = PVE::Storage::config();
+	eval { PVE::Storage::activate_storage($storage_cfg, $opts->{storage}) };
+	if (my $err = $@) {
+	    chomp($err);
+	    $errors .= "could not activate storage '$opts->{storage}': $err";
+	}
+
 	my $info = eval { storage_info ($opts->{storage}) };
 	if (my $err = $@) {
 	    chomp($err);
-- 
2.20.1






More information about the pve-devel mailing list